$(window).load(function() { var s = $('#GallerySlider'); if( s.length != 0 ) { var mu = $('img.mu', s); // move up button; var md = $('img.md', s); // move down button; var sc = $('div.sc', s); // slider content; if( mu.lenght == 0 || sc.lenght == 0 || md.lenght == 0 ) jQuery.error( "ERROR" ); // slider definition; s.content = sc; s.items = $('img', sc); s.position = 0 ; s.isinmove = false; s.step = 98; s.sead = 10; s.spead = 50; s.move = function( direction ) { direction = direction > 0 ? 1 : -1; this.position += direction; alert( (this.position * this.step) +'px' ); this.content.style.marginTop = (this.position * this.step) +'px'; }; // buttons definition; mu.slider = s; md.slider = s; mu.slider.move( 1 ) // tutaj to działa; // move up; mu.click( function() { var t = $(this); t.slider.move( 1 ) // a tutaj już NIE działa; } ); // move down; md.click( function() { alert( 'do' ); this.slider.move( -1 ); } ); } });
Jakby kogoś interesowała odpowiedź to należy wprowadzić następującą zmian:
// move up; mu.click( function() { mu.slider.move( -1 ); } );