javascript - Alert the id name -


if have following code:

<input type="text" id="messagebox" /> 

how id value? notice not $("#messagebox"); want. want alert id name of control. should alert word "messagebox", cus name of id

there couple of ways it.

you can use prop() it:

var id = $("input:text").prop("id"); 

or way:

 var id = $("input:text")[0].id; 

or use get():

var id = $("input:text").get(0).id; 

or can use attr():

var id = $("input:text").attr('id') 

Comments

Popular posts from this blog

Python Kivy ListView: How to delete selected ListItemButton? -

asp.net mvc 4 - A specified Include path is not valid. The EntityType '' does not declare a navigation property with the name '' -