$('div#Categories > div.categories a#showhide').click(function(){
// Get the subManufacturers list
var subCatList = $(this).parent().find('ul#hiddenSubCategories');
// If collapsed do expand
if (subCatList.css('display') == 'none')
{
subCatList.slideDown('slow');
$(this).find('span').html('Hide');
}
else
{
subCatList.slideUp('slow');
$(this).find('span').html('View All');
}
// Stop link from doing anything
return false;
});
以上代码在 IE8、Firefox 和 Chrome 中完美运行(尚未在 Opera 中测试),但仅将点击功能注册到第一个匹配元素,而不是所有匹配它的元素。这是一个已知错误还是该站点独有的错误,因此是其他地方的问题。
最佳答案
$('div#Categories > div.categories a#showhide')
如果您的“a”元素有一个 id,它在页面中应该是唯一的。即,页面上不应有超过一个 ID 为“showhide”的元素。
这可能是 IE 的问题所在。尝试将 id 更改为类名。
关于javascript - jQuery IE7 - 单击仅注册到路径中的第一个元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1526654/