如果按原样运行我的代码(https://jsfiddle.net/Natronox/fhbm3gdq/#&togetherjs=Re8lLHwJMd)我无法点击获取随机图片...即代码无法正常工作。但是,如果我首先将JS放在主体框架中的脚本标签中,它就可以工作。如何在保持JS正确的框架的同时做到这一点?
var games = ["http://cdn.ndtv.com/tech/gadgets/06_hitman.jpg",
"http://img.wallpaperfolder.com/f/6203714F2BE7/deus-ex-1920x1200-412032.jpg",
"http://warnerbros.edelmandigital.us/tumblr/img/header-hero-bg.jpg"
];
function imageChanger(that) {
var imageNumber = Math.round(Math.random() * 2);
while (that.src.indexOf(games[imageNumber]) != -1) {
imageNumber = Math.round(Math.random() * 2);
}
that.src = games[imageNumber];
return false;
};