admin管理员组文章数量:1410712
I want to horizontally scroll a div by clicking on the button Left and Right but it is not working
$('#left').live('click' , function(){
$('#myDiv').scrollLeft(300)
})
$('#right').live('click' , function(){
$('#myDiv').scrollLeft(-300)
})
How can I scroll a div by a bytton click. I also want to remove the scroll bar
JS Fiddle
I want to horizontally scroll a div by clicking on the button Left and Right but it is not working
$('#left').live('click' , function(){
$('#myDiv').scrollLeft(300)
})
$('#right').live('click' , function(){
$('#myDiv').scrollLeft(-300)
})
How can I scroll a div by a bytton click. I also want to remove the scroll bar
JS Fiddle
Share Improve this question asked Jun 25, 2012 at 8:11 Muhammad UsmanMuhammad Usman 11k22 gold badges75 silver badges109 bronze badges2 Answers
Reset to default 3If you don't want to get rid of the scroll bars, why don't you just alter the CSS of the cropped content (i.e. its margin-left
)?
Give the wrapping div
a overflow:hidden
and use the following JS:
$('#left').click(function(){
$('#myDiv').css('margin-left','-300px');
});
$('#right').click(function(){
$('#myDiv').css('margin-left','0');
});
Would look like this.
Is this what you want?
jsfiddle
i used css and margins for scroll, overflow hidden to hide the bar, float to align the pictures and changed some css...
本文标签: javascripthorizontal scroll on clicking buttonStack Overflow
版权声明:本文标题:javascript - horizontal scroll on clicking button - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744981247a2635828.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论