jQuery onClick capture the id of the element
jquery, jquery-selectors
Solution
HTML:
<input type="radio" name="name" id="name" onchange="enableTxt(this)" />
JS:
function enableTxt(elem) {
var id = $(elem).attr("id");
alert(id);
}
Problem
i have many input fields like this ``` <input type="radio" name="name" id="name" onchange="enableTxt()" /> ``` when i click this radio button i wanna capture the id of the radio input. i am using the following code ``` function enableTxt() { var id = $(this).attr("id"); alert(id); } ``` Am getting this error ``` a.attributes is undefined ```