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();
});
精彩评论