我做了四个按钮(input type="button"
)在html,并希望他们点击运行功能,但什么也没发生。
html代码是:
<div id="newtext" style="position:absolute; top:100px;">
<p>this is Text</p>
</div>
<form>
<input type="button" name="moveLayer" value="move Left" onclick="move('left');">
<input type="button" name="moveLayer" value="move Right" onclick="move('right');">
<input type="button" name="moveLayer" value="move Up" onclick="move('up'); ">
<input type="button" name="moveLayer" value="move Down" onclick="move('down'); ">
</form>
脚本是:
function move(direction) {
var layerText = document.getElementByID("newtext");
switch(direction) {
case "left":
layerText.style.left=50;
break;
case "right":
layerText.style.right=150;
break;
case "up":
layerText.style.up=50;
break;
case "down":
layerText.style.down=150;
break;
default:
it is not working;
}
}
谢谢提前…
2条答案
按热度按时间von4xj4u1#
这应该可以工作(没有style.up和style.down这样的东西):
演示:http://jsfiddle.net/GE3C5/2/
elcex8rz2#
layerText.style.up=50;^
layerText.style.down=150;^没有属性up和down。使用top和bottom代替;
默认值:
可能导致语法错误