I have a web page that redirects to another page on click. On the second page I have this:
<?php if(isset($_POST['tab1'])) { ?>
<script>$('#home').trigger('click'); </script>
<?php }?>
The $_POST
comes back ok, only I get this error in the console for the jquery:
In firebug:
TypeError: $("#home") is null
Or in Chrome:
$('#home').trigger('click');
If I run this: alert(document.getElementsByTagName('#home'));
I get a alert with: [object HTMLCollection]
as undefined
If I view the source I can see my jquery there:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js"></script>
<script>
!window.jQuery && document.write('<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.js"><\/script>');
</script>
Any ideas on why the jquery fails?