Click Trigger On Page Load (ul > Li)
I have the following HTML code in my website:
- All
Solution 1:
Problem
The code is triggering the "onclick" event on the li element. You want to trigger the "onclick" event on the "a" element.
Solution
$('#gallery li:nth-child(2) a').click();
Example
See jsFiddle
Solution 2:
If you are perfoming click action on Li tag , then below code will be helpfull.
<div id="gallery"> <ulclass="pictures"><li><ahref="#"data-filter="*"class="active">All</a></li><li><ahref="#"data-filter=".web">Web</a></li><li><ahref="#"data-filter=".design">Design</a></li><li><ahref="#"data-filter=".video">Video</a></li></ul> </div> setTimeout(function () { $('.pictures li:nth-child(1)').trigger("click"); }, 10);
Post a Comment for "Click Trigger On Page Load (ul > Li)"