On Document Ready, Trigger a function that is binded by a click
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");
精彩评论