开发者

changing an images src value when the user scrolls jquery

I'm trying to attach an event handler to the scroll event that changes the value of the image tag's src value by returning a random value from an array of src values (titles)

$( function(titlemagic){

var titles =[

//ive omitted the actu开发者_C百科al array contents in consideration of post length

            ];  

var rand = Math.ceil(100*Math.random())

$('#id').attr('src', function(){ return titles[(rand)] }).scroll();

});


Try this

$(document).scroll(function(){
  var rand = Math.ceil(100*Math.random())
  $('#id').attr('src', function(){ return titles[(rand)] }).scroll();
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜