We help IT Professionals succeed at work.

trigger click not working on table row

Alex Lord
Alex Lord asked
Last Modified: 2018-09-28
    var leadTable = $("#leads-table").find('tr').each(function(){});
    leadTable.on('click', getLeadTimeline);

Open in new window

So in this line of code im searching for tr within a table than on a click on one of these tr it goes to a function,  But im also trying to trigger that click for testing purposes, hinse the first line is the trigger using the id of one of the tr to try and trigger a click on that row, however it isnt working and im clueless to why.
Watch Question

Chinmay PatelChief Technology Ninja
Distinguished Expert 2019

Hi Alex,

Please post the relevant HTML as well. Also did you check if you are getting any errors? depending upon the browser you are using press CTRL+SHIFT+I OR F12 to check the console and see if there are any errors being listed.

Also if you are comfortable spending some extra minutes, create your scenario on https://jsfiddle.net so that it can be quickly accessed by experts.



<table id="leads-table" class="table">
                            <thead class="">
                                <th id="hdr_ENG_DATE" style="">Date</th>
                                <th d="hdr_CHANNEL_TYPE" style="">Channel</th>
                                <th d="hdr_STATUS" style="">Status</th>
                                                              <tr id="396819" class="396819" name="96544">
                                    <td> Feb 09, 2018</td>
                                    <td> Pipeline List import</td>
                                    <td> Closed</td>
                                                              <tr id="104706" class="104706" name="33010">
                                    <td> Aug 06, 2015</td>
                                    <td> Email</td>
                                    <td> Deleted</td>
                                                              <tr id="89295" class="89295" name="34564">
                                    <td> Apr 02, 2015</td>
                                    <td> Email</td>
                                    <td> Closed</td>
                                                              <tr id="22625" class="22625" name="18323">
                                    <td> Nov 12, 2013</td>
                                    <td> Short URL</td>
                                    <td> Won</td>

Open in new window

no errors,
Chief Technology Ninja
Distinguished Expert 2019
This one is on us!
(Get your first solution completely free - no credit card required)
Most Valuable Expert 2018
Distinguished Expert 2019

You need to bind the click event to the trs:

$("#leads-table tr").click(function() { ... });
Most Valuable Expert 2018
Distinguished Expert 2019

Something I forgot to mention - you'll need to do the binding BEFORE you trigger the click:

$("#leads-table tr").click( getLeadTimeline ); 

Open in new window



both answer solved it.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.