horizontal scrolling div onclick with javascript or jquery

前端 未结 4 1274
广开言路
广开言路 2021-02-04 17:11

I have spent the last two days looking for a simple javascript or jquery code for this. I want to incorporate a horizontal scrolling div using javascript or jquery to display i

4条回答
  •  悲哀的现实
    2021-02-04 17:33

    You can do something like this. Not tested code but just giving you a hint.

    Left right
    var imageWidth = 200; $("#left").click(function(){ $("#imageWrapper").animate({marginLeft:"-="+imageWidth}, 500); //Offcourse you need to handle the corner cases when there is not image to move left }); $("#right").click(function(){ $("#imageWrapper").animate({marginLeft:"+="+imageWidth}, 500); });

提交回复
热议问题