Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This only works if row is 0. Why?


I'm trying to fire a trigger on the second cell in any row of a table who's Id is #Item.

What I have tried:

All kinds of versions of lame jquery attempts after googling all night.
Either what I try will only operate on table row 0 or not at all on any row.
Updated 19-Mar-21 11:45am

Thank you.

I will give that a go.
Share this answer
Patrice T 19-Mar-21 17:54pm    
Use 'have a Question or Comment?' button to communicate with author of Solution.
IDs in an HTML document must be unique. Only one element in the document can have the ID Item, so $('#Item') (or document.querySelectorAll('#Item')) will only ever return a single element.

Based on your description, your table's ID is Item. If you call $('#Item').eq(1) you are asking for the second element in the document with the ID Item, which obviously can't exist.

I suspect you want something like:
$('#Item tr').eq(row).trigger('change');

NB: If you have nested tables, this will not work properly; the rows of the nested tables will also be matched by the tr selector.

Assuming you've structured your table properly, you'll need:
$('#Item > tbody > tr').eq(row);
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900