我剛開始使用Javascript。我已經通過代碼onchange事件實施了JS:使用Javascript更改Onchange事件的內容
<html>
<head>
<script>
function fun()
{
var x=document.getElementById("price1");
document.forms['forms1'].price.value=x.value*2;
}
</script>
</head>
<body>
<form name="forms1">
Enter Price: <input type="text" id="price1" onchange="fun()">
value is: <input name="price" type="text" >
</form>
</body>
</html>
但問題是,我得到這樣
值輸出爲:| _ _ |
但我想它像一個段落沒有input tag
(即不在框中)。我希望它能像文本一樣改變。例如value is: 20
而不是value is:|___20___|
。任何幫助?
要麼設置'innerHTML'一個'p'標籤或與CSS你輸入刪除邊框。 – Mathletics
http://jsfiddle.net/mdUHU/ – Ryan