Run button on page load
I have this function
$("a#<?php echo $custom_jq_settings['toggle']; ?>").click(function() {
jQuery("#<?php echo $custom_jq_settings['div']; ?>").slideToggle(400);
jQuery("#featurepagination").toggle();
jQuery("#featuretitlewrapper").toggle();
return false;
});
And this is the button that I want to call when the page loads
<a href="#" id="featuretoggle" onclick="changeText('<?php if (is_front_page()) {?>Show<?php } else { ?>Show<?php } ?> Features');"><?php if (is_front_page()) {?>Hide<?php } else { ?>Hide<?php } ?> Features</a>
I would like to launch this button when the page loads so that it starts to open, but then the slide / closes
click jQuery:
$('#featuretoggle').click();
:
$(document).ready(function() {
$('#featuretoggle').click();
});
, , , , $(document).ready().
See an example :
<a href="#" id="someButton">Foo</a>
<script type="text/javascript">
$(document).ready(function() {
// bind the click event
$('#someButton').click(function() {
alert('baz');
});
// trigger the click event
$('#someButton').click();
});
</script>