Quantcast
Channel: Get id of an element through a function - Stack Overflow
Viewing all articles
Browse latest Browse all 5

Get id of an element through a function

$
0
0

I have a function that is called in an onclick event in a checkbox field.

<input type='checkbox' checked='' onclick='return changeEnable();' id='someid'>

and the function

function changeEnable(){    var val = $(this).attr('id');    alert(val);}

I have that but it returns undefined. Is my syntax wrong or did I miss something?

Those checkboxes are dynamically created and have different id's, that's why I want to get the id for some task.


Viewing all articles
Browse latest Browse all 5

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>