我有一个网页在点击时重定向到另一页。 在第二页上我有这样的:
<?php if(isset($_POST['tab1'])) { ?>
<script>$('#home').trigger('click'); </script>
<?php }?>
的$_POST
伤愈复出没关系,只是我在控制台中对jQuery的这个错误:
在Firebug:
TypeError: $("#home") is null
还是在Chrome:
$('#home').trigger('click');
如果我运行这个:alert(document.getElementsByTagName('#home'));
我得到一个警报,提供:[object HTMLCollection]
为undefined
如果我认为我可以看到我的jQuery有来源:
<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>
为什么jQuery的失败,任何想法?