1

Im having some trouble with jQuery's slideToggle function in IE8 for some reason the DIV its opening closes immediately after its opened

heres the code im using

$("h3 a").click(function(){
    id = $(this).attr("href");      
    $(id).slideToggle("slow");
});

and the HTML

<h3><a href="#promo-materials">Graphic and Pormotional Materials</a></h3>
    <div id="promo-materials" class="center gallery">
        <a href="images/portfolio/bistro.png" rel="facebox">
            <img src="images/portfolio/thumbs/bistro.png" alt="" />
        </a>
        <a href="images/portfolio/direct-savings.png" rel="facebox">
            <img src="images/portfolio/thumbs/direct-savings.png" alt="" />
        </a>
     </div>

Here is a link to the functional page it works in all other browsers including IE7

I forgot to post it:

http://bestprintideas.com

I currently have it triggering Compatiblity Mode since I had to get to work today.

1
  • It sounds like your event handler is being bound twice, an reason this might be the case? Commented Apr 22, 2010 at 21:46

3 Answers 3

3

Remove this style from the h3 right before the gallery

display: inline-block;

that seems to fix the problem in IE8.

0
0

I am betting Nick's comment about it being fired twice is the answer. I copied your code above and it works great for me in IE8.

0

You could try this:

$("h3 a").click(function(){
    id = $(this).attr("href");
    $('#' + id).slideToggle("slow");
});
3
  • The only problem is that i do this for multiple "h3 a" that point to different DIVs
    – jef2904
    Commented Apr 22, 2010 at 22:40
  • @jef2904: see my answer, updated, i think that should do the trick. you were not adding the # in your selector.
    – Sarfraz
    Commented Apr 22, 2010 at 23:07
  • His href has a # in it already, it's in the code he posted...and that wouldn't explain why only IE8 has the issue. Commented Apr 22, 2010 at 23:37

Not the answer you're looking for? Browse other questions tagged or ask your own question.