Phill Pafford Phill Pafford - 9 months ago 60
jQuery Question

jQuery call function after load

Need to call a filter function on some options based on a radio selected (Link here), How can I call this after the page is loaded? the radio is set from a DB call and I would like to filter the options



$(document).ready(function () {
  // Function code here.

Or the shorter but less readable variant:


All of these will cause my_function to be called after the DOM loads.

See the ready event documentation for more details.

Binds a function to be executed whenever the DOM is ready to be traversed and manipulated.


To simulate a click, use the click() method without arguments:


From the docs:

Triggers the click event of each matched element. Causes all of the functions that have been bound to that click event to be executed.

To put it all together, the following code simulates a click when the document finishes loading:

$(function () {