I have an ajax form that returns a list and puts it into an HTML table. I plan on using a click event in the Complete section of the ajax call but am unsure how to proceed.
What I need is a method that will be able to:
- determine if there are any rows in the table, and
- send a click event to that row.
I know how to do the click event, its the dynamic table that’s causing me the pause.
Appreciate the help.
Didn’t not test it, but this should do the job :
Put whatever the ID of your table is, class, or whatever and select all sub-elements
tr. With the function length, she will return the number oftrinside your table. As you may know, eachtris a row.So in final, your code will look like this :
If you want to click the first row, no matter what you can do this :
However, clicking a row isn’t the best idea since a row ain’t a link. If you want to click a link inside a
TD, you can try this :Didn’t try the last one so I don’t know if it work.