javascript - Trigger the click JS code on page load through JQuery -
i running following code on link:-
$('#expertprofiles-category-filters .filterby > a').on("click", function () { // figure out category show. var categoryid = $(this).attr('rel'); // hide other subfilters. $("div.category-panel[rel!=" + categoryid + "]").slideup(100); // show subfilters of category. $("div.category-panel[rel=" + categoryid + "]").delay(100).slidedown(400); }); this code runs fine problem want run code on page load too, 1 link autaomatically selected.
i tried this:-
$("#expertprofiles-category-filters .filterby").find('a').trigger('click'); but doesn't work ...
thanks.
you may following way,
$('#expertprofiles-category-filters .filterby > a').on("click", function () { // figure out category show. var categoryid = $(this).attr('rel'); // hide other subfilters. $("div.category-panel[rel!=" + categoryid + "]").slideup(100); // show subfilters of category. $("div.category-panel[rel=" + categoryid + "]").delay(100).slidedown(400); }).trigger("click"); // triggers click on dom ready
Comments
Post a Comment