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
Post a Comment