在我的jQuery代码中,removeClass
无效。每当我点击hide
链接时,IE6.0中的.close
元素都没有删除,但它在firefox和IE8.0中有效,下面是我的jQuery代码:
$(document.ready(function()){
toggleNodes = function(node,action){
var $componentone = $('.componentone', node);
if (action == undefined || action == 'hide'))) {
$componentone.addClass('closed');
$componentone.hide();
}
else if (action=='undefined'||action=='view'){
$componentone.removeClass('closed');
$componentone.show();
}
}
});
`close'在.css文件中声明如下:
.componentone{
margin-left:10px;
padding-left:15px;
border:1px solid #fff;
border:0px solid #ddd;
}
.componentone.closed{
margin-left:10px;
padding-left:15px;
border:1px solid #fff;
border:0px solid #ddd;
}
在JSP中我使用过它:
<div="componentone">body of div</div>
<div="component">body of div new</div>
答案 0 :(得分:2)
你的其他条件有语法错误
else if { (action=='undefined'||action=='view')
$info.removeClass('closed');
$componentone.show();
}
to
else if (action=='undefined'||action=='view'){
$info.removeClass('closed');
$componentone.show();
}