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(my_function);
Or
$(document).ready(function () {
// Function code here.
});
Or the shorter but less readable variant:
$(my_function);
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.
Edit:
To simulate a click, use the click() method without arguments:
$('#button').click();
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 () {
$('#button').click();
});
In regards to the question in your comment:
Assuming that you've previously bound your function to the click event of the radio button, add this to your $(document).ready
function:
$('#[radioButtonOptionID]').click()
Without a parameter, that simulates the click event.