tga*_*ews 1 javascript jquery internet-explorer-7 internet-explorer-6
$('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;
});
Run Code Online (Sandbox Code Playgroud)
上面的代码在IE8,Firefox和Chrome中完美运行(尚未在Opera中测试),但仅将click函数注册到第一个匹配元素而不是所有匹配元素.这是一个已知的错误或该网站独有的东西,因此在其他地方是一个问题.
$('div#Categories > div.categories a#showhide')
如果您的'a'元素具有id,则它在页面中应该是唯一的.也就是说,页面上不应该有多个id为"showhide"的元素.
这可能是搞乱IE的原因.尝试将id更改为类名.
| 归档时间: |
|
| 查看次数: |
720 次 |
| 最近记录: |