我有一个元素
<input type="text">
Run Code Online (Sandbox Code Playgroud)
在这方面,有一个事件
onChange="myfunction(param)".
Run Code Online (Sandbox Code Playgroud)
"param"是输入本身的内容.我如何处理,当我触发onChange(如此完成字段的更改)时,在此参数中该字段的实际值是多少?
有可能做这样的事情:
onChange="myfunction(document.getElementById('this_id'))"
Run Code Online (Sandbox Code Playgroud)
hun*_*ter 22
你可以传递this到myFunction哪个input
<input type="text" onChange="myfunction(this)" />
Run Code Online (Sandbox Code Playgroud)
那么myFunction看起来像这样:
function myFunction(obj)
{
var value = obj.value; // the value of the textbox
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
22882 次 |
| 最近记录: |