jquery accessing data() attached to tr rows

ShanghaiD
ShanghaiD used Ask the Experts™
on
I have successfully "attached" data() to each tr table row in my table.  I know it is there as I can see it in Firebug using Firequery.  I can also successfully query the tr data, as follows:

var $theRows = $('#tsTable tbody tr').filter(function() {return $(this).data('ocB')!='0.00' });

This filters down the tr rows to only those with attached data('ocB') which are not zero value.
In the the 3rd td of each row there is a <ul = class"oc" /> tag.
I can successfully insert text into each of the ul tags in each 3rd td of each of the filtered rows by using:

$theRows.find('.oc').text('my inserted text');

However, what I really want to do (and this is my problem) is to insert the value of the data('ocB') attached to each row into each ul tag [instead of 'my inserted text'].  I tried to do this with:

$theRows.find('.oc').text($(this).parent().parent().data('ocB'));
but this does not produce anything.  

Can anyone help me solve my problem?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Consultant & Challenge Subduer
Top Expert 2009
Commented:
The context doesn't change. If you can check the value with

$(this).data('ocB')

then you can read it the same way:

$theRows.find('.oc').text($(this).data('ocB'));

That might not work though because you've shown us very little of your code. By the way, you shouldn't add text directly to a <ul> element. You should put the text in an <li> element inside the <ul> element..

Author

Commented:
I did not make it easy by giving very little of my code, but your comments have lead me to a successful solution, so I am happy to give you the points.
The data('ocB') is attached to each tr inside which there are several tds with one td having inside it a ul (and now also a li !) of class 'oc'.
I got things to work by modifying the syntax slightly to:
$theRows.each(function(){$(this).find('.oc').text('$(this).data('ocB'))});

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial