Skip to content
Advertisement

Get the id of input on keyup

I have an input box…

JavaScript

When I type in the field, it will go to function lookup(). From there I want to get the id of this input. I tried…

JavaScript

but this won’t work. Any suggestions on how I can get the id?

Advertisement

Answer

Because you are passing this.value to your lookup() function. It’s better to pass this to your function and then use arg.value to get the value and arg.getAttribute('id') for the id

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement