trigger click not working on table row

$("#396819").trigger('click');
    
    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.
Alex LordAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chinmay PatelChief Technical NinjaCommented:
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.

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

Open in new window


no errors,
0
Chinmay PatelChief Technical NinjaCommented:
Hi Alex,

Please try this jsfiddle : http://jsfiddle.net/xpvt214o/854269/
I am able to call the function defined on the HTML.

Regards,
Chinmay.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Chris StanyonWebDevCommented:
You need to bind the click event to the trs:

$("#leads-table tr").click(function() { ... });
0
Chris StanyonWebDevCommented:
Something I forgot to mention - you'll need to do the binding BEFORE you trigger the click:

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

Open in new window

0
Alex LordAuthor Commented:
Thanks

both answer solved it.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.