tags:

views:

64

answers:

2

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
});
+4  A: 

'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");
redsquare
Hey.. right.. how did I miss this :( ..Thanks @Vilius as well)
Ajay
+1  A: 

you can get attribute value like that:

$("input[name=grp1]").click(function() {
    alert($(this).attr("myUDF"));
});
Vilius Pau