Nikola Nastevski
Nikola Nastevski

Reputation: 937

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.

Upvotes: 0

Views: 1004

Answers (2)

Matt Ball
Matt Ball

Reputation: 359786

$(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>

Upvotes: 2

BNL
BNL

Reputation: 7133

Assuming jquery.

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

Upvotes: 1

Related Questions