![](/img/trans.png)
[英]jquery toggle not working in chrome but working in IE and firefox
[英]jQuery toggle not working in IE
我有一些jQuery代碼在IE之外的所有其他軟件上都可以正常工作。 切換動作不會觸發,也不會隱藏或顯示頁腳元素。
我試圖使用條件if和else語句來使用hide()和show()來代替切換,我也試圖將language和src元素添加到script標簽中,但是這些角度都不起作用。 我聲明了最新的doctype,並且使用的是最新版本的wordpress。
誰能看到為什么這在IE中不起作用?
<script>
$(document).ready(function() {
$("#clickme").click(function() {
event.preventDefault()
$("#footer").toggle(2000);
$('#menu, #menu2, #menu3, #menu4').hide('slow');
$(this).html(($('#clickme').text() == 'Show') ? 'Hide' : 'Show');
$(this).toggleClass("active");
$(this).attr("title", ($(this).hasClass("active") ? "Show" : "Hide") + " the menu");
});
});
</script>
您正在使用
$("#clickme").click(function() {
event.preventDefault();//^ event parameter is missing, so causing error
// ...
});
它應該是
$("#clickme").click(function(event) {
event.preventDefault(); // ^
// ...
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.