开发者

On Document Ready, Trigger a function that is binded by a click

开发者 https://www.devze.com 2022-12-16 11:57 出处:网络
I have a function in a JavaScript like so: $(\"#table-filters li\").click(function(){ **开发者_运维百科* Lots of stuff here...

I have a function in a JavaScript like so:

$("#table-filters li").click(function(){ **开发者_运维百科* Lots of stuff here...
});

What I would like to happen is when the page loads, to one-time, run that function. Something contained in:

$(document).ready(function() { 
});

Suggestions?

Thanks!


$(function(){ 
  $("#table-filters li")
    .click(function(){
      // Lots of stuff here...
    })
    .slice(0,1).click();
});


Use this:

$("#table-filters li").trigger("click");


$("#table-filters li:first").trigger("click");

0

精彩评论

暂无评论...
验证码 换一张
取 消