我有下面的JQuery代码,我需要清除这个动画所做的内联css
$(document).ready(function(){
$("#panel").hide(); //updated line, removing the #panel ID.
$('#tab2').toggle(function(){ //adding a toggle function to the #tab
$("#panel").show();
$('#ToolsTitleSpan').text("CLOSE TOOLS");
$('#tab2').stop().animate({right: '225'}, 800, 'swing', function() {});
$("#panel").stop().animate({right: '72', width: '230px', opacity:0.8}, 800, 'swing', function() {
$('.contentSideBar').fadeIn('slow');
});
},
function(){ //when the #tab is next cliked
$('#ToolsTitleSpan').text("OPEN TOOLS");
$('#tab2').stop().animate({right: '-=225'}, 800, 'swing', function() {
$('.contentSideBar').fadeOut(slow, function() {});
});
$('#panel').stop().animate({width:"0", position:'absolute', float: 'right', opacity:0.1}, 800, 'swing');
});
});如果需要,下面是HTML代码:
<div id="panelKS"> <!--the hidden panel -->
<div class="contentSideBarKS">
</div>
</div>
<div id="tab2KS">
<span id="ToolsTitleSpanOpenKS">
<img id="bg" src="<?php echo $OUTPUT->pix_url('/buttons/opentools', 'theme')?>"/>
</span>
<span id="ToolsTitleSpanCloseKS">
<img id="bg" src="<?php echo $OUTPUT->pix_url('/buttons/closetools', 'theme')?>"/>
</span>
</div>你能告诉我怎样才能清除内联css吗?
谢谢
发布于 2013-04-01 17:10:55
您可以在CSS中使用!important:
.test{
right:800px !important;
} 这段代码会让你的内联css被忽略。
或者,您可以使用以下命令获取DOM的属性style:
$("div.test").attr("style",""); 或者:
$("div.test").attr({style : ""});你可以使用你更喜欢的解决方案。
发布于 2013-04-01 18:24:02
也许这可以解决你的问题,抱歉双重发帖(字符不足的原因)
<!doctype html>
<html>
<head>
<style>
#panelKS{
width : 500px;
background-color:#f0f;
display:none;
}
#tab2KS{
width : 500px;
background-color:#fa0;
display:inline-block;
position:absolute;
}
</style>
</head>
<body>
</body>
<div id="panelKS"> <!--the hidden panel -->
<div class="contentSideBarKS">
Testing
</div>
</div>
<!-- my assumtion is -->
<div id="tab2KS">
<span id="ToolsTitleSpanOpenKS" value="1">
<img id="bg" src="#" alt="image 1" title="image 1"/>
</span>
<span id="ToolsTitleSpanCloseKS" value="2">
<img id="bg" src="#" alt="image 2" title="image 2"/>
</span>
</div>
<script src="scripts/jquery-1.9.0.min.js"></script>
<script>
$("#tab2KS").children().click(function(){
$("#panelKS").css({display:"inline-block"});
//after that in your css you could set transparency to 0 and do the animation
});
</script>
<body>
https://stackoverflow.com/questions/15740321
复制相似问题