0
我想要的id="insertValue"
值函数insert()
单击按钮时转移到可变X
...如何将输入文本中的值传输到按钮?
<input id="insertValue" type="text" />
<input type="button" value="Insert" onclick="insert('x')" />
我想要的id="insertValue"
值函数insert()
单击按钮时转移到可变X
...如何将输入文本中的值传输到按钮?
<input id="insertValue" type="text" />
<input type="button" value="Insert" onclick="insert('x')" />
insert(document.getElementById('insertValue').value)
应该这样做。
但你的问题与ajax无关...
试试这个。
JS:
function insert(e){
myValue = document.getElementById('insertValue').value;
// myValue is now set to the contents of the text field 'insertValue'
// let's check it...
alert(myValue);
}
HTML:
<input id="insertValue" type="text" />
<input type="button" value="Insert" onclick="insert(this)" />
我不明白,如果你也想在按钮的值设置为文本字段的内容。如果你想(并且没有理由你需要),只需将它添加到JS函数中即可。
e.value = myValue;
感谢这是工作好:) – user2309096 2013-04-22 22:35:55