我正在制作的页面上的 hide()
函数出现问题。目前,选定的 div 图层并未隐藏。
在 Safari 和 Chrome 中一切正常,但不幸的是在 Firefox 中不行:-(
该页面位于上下文中:http://www.upreach.org.uk/undergraduates/partners.php这是我的代码:
$(document).ready(function(){
$('div.partner-employers').not('div#start').hide();
$("a.employers").click(function(){
$("a.employers").css("font-weight", "normal");
$(this).css("font-weight", "bold");
var myelement2 = $(this).attr("href")
$(myelement2).fadeIn("fast");
event.preventDefault();
$(".partner-employers:visible").not(myelement2).hide();
});
});
...和 HTML:
<a href="#1" class="employers">1</a><br/>
<a href="#2" class="employers">2</a><br/>
<a href="#3" class="employers">3</a><br/>
<div class="partner-employers" id="1">Content for 1</div>
<div class="partner-employers" id="2">Content for 2</div>
<div class="partner-employers" id="3">Content for 3</div>
预先感谢您提供的任何帮助...
最佳答案
您正在使用未定义的 event
变量,因此代码在执行最后一行之前崩溃。在 IE 中,这是在 window
对象中定义的,但在大多数其他浏览器中并非如此。
在函数签名中定义事件
参数:
$("a.employers").click(function(event){
关于javascript - 使用 Firefox 的 jQuery hide() 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18988225/