I have input tags with a user defined attribute as:-
<input name="grp1" type="radio" myUDF="value1" />
<input name="grp1" type="radio" myUDF="value1" />开发者_开发百科;
How can i extract the value of myUDF?
The scenario is :-
$("input[name=grp1]").click(function(){
this.attr("myUDF"); // This throws the exception Object doesnt support this prop or mehod
});
'this' is the dom object - not a jquery object therefore it does not have the attr function.
You need to create a jq object with this e.g
$(this).attr("myUDF");
you can get attribute value like that:
$("input[name=grp1]").click(function() {
alert($(this).attr("myUDF"));
});
精彩评论