LOKESH
LOKESH

Reputation: 1301

jquery to change td2 value where td1 match

I want to change td2 value where td1 match. For example I have column macaddress and renewalstatus. I want to set Renewal status=Requested where macid is 54564564654A through jquery

MAC Address     Renewal Status
54564564654A    Renewal Due
545645646546    Renewal Due

I have code that change match value but not other td

$("td:contains('54564564654A')").text("Value 1.TO-THE-MAX");

Above code change 54564564654A to Value 1.TO-THE-MAX. But I want to change Renewal status to Requested. Where macid match.

Upvotes: 1

Views: 56

Answers (1)

Shubham Khatri
Shubham Khatri

Reputation: 281892

Get to the parent tr using closest() and then find the second column using the nth-child(2) selector on td

$("td:contains('54564564654A')").closest('tr').find('td:nth-child(2)').text("Requested");

Upvotes: 2

Related Questions