I've got an element
<input type="text">
On this, there is an Event
onChange="myfunction(param)".
"param" is the content of the input itself. How can I handle, that, when I fire onChange (so complete the change of the field), in this param is the actual value of this field?
Is it possible to do something like that:
onChange="myfunction(document.getElementById('this_id'))"
You can pass this
to myFunction
which will be the input
<input type="text" onChange="myfunction(this)" />
then myFunction
could look like this:
function myFunction(obj)
{
var value = obj.value; // the value of the textbox
}
Inside an inline event handler, this
will refer to the DOM element.
Therefore, you can write onchange="myfunction(this)"
to pass the DOM element itself to the function.
To get the .value
inline, it would look like this:
<input type="text" onchange="myfunction(this.value)" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With