简体   繁体   中英

How can I trigger('click') on page load with this specific code

How can I make this happen, on page load?

<a onclick="$('a[href=\'#tab-review\']').trigger('click');"><?php echo $text_write; ?></a>

Thanks.

$(window).load(function ()
{
    $('a[href="#tab-review"]').click();
});

RTFM .


Hm, any idea how to put this between I need this to be executed with IF...?

<script>
function clickTheLink()
{
    $('a[href="#tab-review"]').click();
}

<?php
if ($something) {
  echo '$(window).load(clickTheLink);';
}
?>
</script>

Assuming jquery.

<script>
$(function () {
    $('a[href="#tab-review"]').trigger('click');
});
</script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM