Javascript 如何将值从输入文本传输到按钮?
单击按钮后,我想将Javascript 如何将值从输入文本传输到按钮?,javascript,Javascript,单击按钮后,我想将id=“insertValue”的值转移到函数insert()中的变量X <input id="insertValue" type="text" /> <input type="button" value="Insert" onclick="insert('x')" /> 插入(document.getElementById('insertValue').value)应该这样做 但是你的问题与ajax无关…试试这个 JS: HTML: functio
id=“insertValue”
的值转移到函数insert()
中的变量X
<input id="insertValue" type="text" />
<input type="button" value="Insert" onclick="insert('x')" />
插入(document.getElementById('insertValue').value)
应该这样做
但是你的问题与ajax无关…试试这个
JS:
HTML:
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);
}
<input id="insertValue" type="text" />
<input type="button" value="Insert" onclick="insert(this)" />
e.value = myValue;