Happydevdays Happydevdays - 2 months ago 4x
jQuery Question

can't save an object and pass to another method

I have the following code inside a table:

<tr class="16225">
<td class="grp_memberships">&nbsp;</td>
<td><a href''="">Edit</a> | <a href="">Delete</a></td>

After the page has been rendered, I'm making an ajax call to get values for the "grp_memberships" cells.
The class value I have on the
is actually an ID. I want to find/match rows based on this ID , and then populate the value of the grp_memberships

I can find the row using this in the console window:


That returns the entire row. But I don't know how then to update the
with the value...

Here's the jquery code i have right now:

$.each(groups, function(i, e) {
console.log(e['id'] + '-' + e['grp']);


contains the value of the class that should match the



In the console window, I tried this:

$('.16225 .grp_memberships').text('hello');

And that returned and updated the right cell for me.

So I tried to update my code to look like this:

$.each(groups, function(i, e) {
$('.' + e['id'] + ' .grp_memberships') = e['name'];

That outputs the following error:

Uncaught ReferenceError: Invalid left-hand side in assignment

I also tried this:

$("'." + e['id'] + " .grp_memberships'") = e['name'];

But that returns this error:

caught Error: Syntax error, unrecognized expression: '.16233


Latest Code:

$.each(groups, function(i, e) {
$('.' + e['id'] + ' .grp_memberships').text(e['name']);

This displays a message box 2 times with the various names... but the corresponding rows in the table are not updated.


Try this:

$("'." + e['id'] + " .grp_memberships'").text(e['name']);