There’s a div2 here that has transparency using a css style tag. However the transparency goes away after toggle. It seems to work fine with toggle() but not toggle([number]).
Any fixes? Thanks guys.
doesn’t work in IE7 OR FF 3.5
CSS
.transparentDiv
{
filter:alpha(opacity=50);
background-color:#d5ffd5;
height:800px;
width:300px;
}
CODE
<input type="button" id='btn1' value="Hide Something" />
<div style=" background-image:url('../../images/bg.jpg'); background-repeat:repeat-x; border-style:solid;height:1000px;width:100%">
<div id="div3" class="transparentDiv" style=" margin-top:30px; padding-left:300px;background-color: #4ddfff; height: 100px;position:absolute; width:950px">
<br />
<br />
<br />
</div>
<div id="div2" class="transparentDiv" >
<h1></h1>
</div>
</div>
<script src="http://jquery.com/src/jquery-latest.js"></script>
<script type="text/javascript">
$(function() {
$("#table1 tbody tr:even").addClass('zebra');
$("#btn1").click(function() {
$('#div2').toggle(400); return false;
});
});
</script>
its because you use
$('#div2').toggle(400);it is fading + sliding, i think the browser (IE) overwrites the value when animating so when toggling back, it just goes up.EDIT: possible solutions
1: use slideFadeToggle form this blog:
EDIT2: found out this is not really working in IE either… if you really want the fade you have to do it manually, eg check if the div is active then toggle(400) else animate({…},400)
2: just use the build in slideToggle, it uses no fading:
Good luck