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"> <ul class="pictures"> <li><a href="#" data-filter="*" class="active">All</a></li> <li><a href="#" data-filter=".web">Web</a></li> <li><a href="#" data-filter=".design">Design</a></li> <li><a href="#" 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)"