user505689
user505689

Reputation: 81

unable to read the attribute value using jquery

I am using this method on rowmouseevent

$get(eventArgs.get_id()) gives the ouput as

<tr class="normal" data-value="normal" id="ctl00_ContentPlaceHolder1_UserGrid_grdusergrid_ctl00__0" style="height:30px;" /tr>

How can I get the "class" attribute value of that

I am trying like

$get(eventArgs.get_id()).attr("class")

which is throws error as below "Object # has no method 'attr'"

Thanks

Upvotes: 0

Views: 182

Answers (6)

Shaik Rilwan
Shaik Rilwan

Reputation: 355

try this

$('#'+$get(eventArgs.get_id())).attr("class");

Upvotes: 0

Rajesh Kumar
Rajesh Kumar

Reputation: 2503

$get is a function from the (now depreciated) ms ajax core JavaScript library and attr is jquery function. So you have to wrap your $get element with $(Jquery) to use attr like:

$($get(eventArgs.get_id())).attr("class")

or If you know the element id then you can directly use

$('#Id).attr("class")

Upvotes: 2

Justus Romijn
Justus Romijn

Reputation: 16019

If $get (don't know what that is) really returns that HTML node, you still have to wrap it with jQuery to enhance it with all the features, like attr:

$get(eventArgs.get_id()) // return <tr class="normal" ... etc ...
$($get(eventArgs.get_id())) // returns jquery object, with <tr class="normal ...
$($get(eventArgs.get_id())).attr("class") // now you can do this

Upvotes: 1

Marshall Farrier
Marshall Farrier

Reputation: 967

$($get(eventArgs.get_id())).attr("class")

Upvotes: 1

Ringo
Ringo

Reputation: 3965

Try this:

var className = $('<tr class="normal" data-value="normal" id="ctl00_ContentPlaceHolder1_UserGrid_grdusergrid_ctl00__0" style="height:30px;" ></tr>').attr('class');

or

 var obj = $("'" + $get(eventArgs.get_id() + "'").attr('class');

Upvotes: 0

Royi Namir
Royi Namir

Reputation: 148524

Try this :

$('#'+$get(eventArgs.get_id())).prop("class");

Upvotes: 0

Related Questions