我正在尝试获取脚本src =" jsmovermap1.js"更改为脚本src =" jsmovermap2.js"当用户在键盘上单击“向上”时。当你查看页面元素时,我似乎有这个工作,但页面没有更新到js源。您对如何克服这个问题有任何建议吗?
非常感谢!!!
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Ireland Map</title>
</head>
<body>
<div id="map">
</div>
<script src="jquery-2.1.1.min.js"></script>
<script src="raphael-min.js"></script>
<script src="jsmovermap1.js" id="s1"></script>
<script>
x=1;
alert(x);
document.addEventListener('keydown', function (evt) {
if (evt.keyCode === 38) {
alert('The "UP" key is being held down...?');
x=x+1;
alert(x);
s1.src="jsmovermap"+(x)+".js"
//s1.src = s1.src.replace("jsmovermap1.js","jsmovermap"+(x)+".js");
}
if (evt.keyCode === 40) {
alert('The "DOWN" key is being held down...?');
x=x-1;
if(x<0){
x=0}
alert(x);
}
});
</script>
</body>
</html>
答案 0 :(得分:0)
答案 1 :(得分:0)
也许这个例子可以帮到你