Help with .click .animate having to click twice in IE
Hi all,
I have written some Jquery code to animate a div, basically a horizotal sliding drawer. The problem is, it has to be clicked twice in IE 7 to make it work, but only once in FF and safari like it should. Any help would be greatly appreicated.
Thanks.
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script src="lib/jquery/jquery-1.3.2.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#rtbutton").click(function() {
var $marginRt = $('.rtinner');
$marginRt.animate({
marginRight:parseInt($marginRt.css('marginRight'),0)==0?$marginRt.outerWidth():0
});
});
$("#rtbutton").click(function() {
$(".horzarrows").toggleClass("bgposition"); return false;
});
});
</script>
<style>
body {
margin: 0;
}
.rtslide {
width: 100%;
overflow: hidden;
position: absolute;
float: right;
}
.rtinner {
background: url(images/slide_img.png) no-repeat 0px 0px;
position: relative;
width: 250px;
height: 162px;
right: -250px;
float: right;
}
#rtbutton {
background: url(vert_slidebtn_img.png) no-repeat 0px 4px;
width: 38px;
height: 153px;
margin-left: -30px;
float: left;
}
.horzarrows {
background: url(images/horz_arrows.png) no-repeat 12px 0px;
width: 73px;
height: 10px;
float: left;
margin: 18px 0 0 0;
}
.bgposition {
background-position: -49px 0px;
}
</style>
</head>
<body>
<div class="rtslide">
<div class="rtinner">
<div id="rtbutton">
<div class="horzarrows"></div>
</div>
</div>
</div>
</body>
</html>