Forum Moderators: open

Message Too Old, No Replies

Accordion and JQuery

Breaks in IE6 when the slide contains an image inside the div

         

SilverLining

5:17 pm on Dec 22, 2009 (gmt 0)

10+ Year Member



This Accordion JQuery works fine when no image is placed within the "content" div. Once an image is placed within the "content" div, the slide functionality no longer works in IE6.

I have pulled the code out, but not it doesn't even work on my local machine.

Firefox and other browser don't complain about any JavaScript errors and IE6 is not an easy browser to debug.

If you notice anything out of place or incorrect, please let me know. Thanks


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Test</title>
<style type="text/css" media="screen">
#test { border: 1px solid red; }
.heading { cursor: pointer; }
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$('.heading').click(function(){
expand_blah($(this));
});
});
var expand_blah = function( element )
{
// Check to prevent animation on already expanded element
if ( $(element).next('.content').css("display") != "none" ) {
return;
}
var blah = $(".content");
$(".arrow").css({"background-position" : "0px 0px"});
blah.slideUp("fast", function() {
$(element).children(".arrow").css({"background-position" : "0px -9px"});
$(element).next('.content').slideDown("slow");
});
};
</script>
</head>
<body>
<div id="test">
<h1>Test</h1>
<div class="heading">
Heading 1
<div class="arrow" style="background-position: 0px 0px;"/>
</div>
<div class="content" style="display: none;">
<img width="60" height="56" border="0" src="logo.gif"/>
1111111 Details<br/>
</div>
<div class="heading">
Heading 2
<div class="arrow" style="background-position: 0px -9px;"/>
</div>
<div class="content" style="display: none;">
<img width="60" height="56" border="0" src="logo.gif"/>
2222222 Details<br/>
</div>
</div>
</body>
</html>

Fotiman

4:12 pm on Dec 30, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




<div class="heading">
Heading 1
<div class="arrow" style="background-position: 0px 0px;"/>
</div>

My guess is that the self-closing <div /> is causing a problem. Try changing that code to this:

<div class="heading">
Heading 1
<div class="arrow" style="background-position: 0px 0px;"></div>
</div>

And let us know if that works.

SilverLining

1:31 pm on Jan 5, 2010 (gmt 0)

10+ Year Member



I have fixed this in the mean time by removing "commented-out" code and a combination of cleanups.

With regard to the <div /> causing the error, the actual code is <div></div>, but when I copied the HTML, Firebug converted it to <div /> and I overlooked this when I pasted it here. Thank you for the suggestion.