Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Aug 2008
    Posts
    105
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Smile Why wont it work in IE?

    Code:
              $(".specialistContainer h5").click(function(){
                            $(this).parents(".specialistContainer").find(".twistyContent").toggle();
                            var theSpan = $(this).children('span').text();
                            if (theSpan == "+") {
                              $(this).children('span').text("-");
                            } else {
                              $(this).children('span').text("+");
                            }
                
                var theUnderline = $(this).css('text-decoration');
                if (theUnderline == "underline") {
                  $(this).css("text-decoration","underline");
                } else {
                  $(this).css("text-decoration","none");
                }
    
                    }); 
    
    
    ...
    
    <div id="oldham0" style="color: black; display:none; margin-bottom: 6px;">
        <div class="specialistContainer">
            <h5 style="color: #000;">company name</h5>
                <div class="twistyContent" style="display: none;">
                    Unit 3, Coldhurb Ind Estate
                    <br/>
                    Coldhurst Street
                    <br/>
                    Oldham
                    <br/>
                    Lancashire
                    <br/>
                    OL1 2BQ
                    <br/>
                    0161 624 5555
                </div>
                <a href="mailto:info@company.com" style="color: #000;font-weight: bold;">info@company.com</a>
                <a href="http://www.company.com" target="_blank" alt="company" title="company" style="color: #000;">www.company.com</a>
        </div>
    </div>
    That click listener doesn't get attached no matter what I do! I've confirmed that the other functions work, such as the toggle();, and it ALL works in firefox... what is going on?

  • #2
    Regular Coder
    Join Date
    Aug 2008
    Posts
    105
    Thanks
    9
    Thanked 0 Times in 0 Posts
    I found the solution:


    live("click", function()


    instead of

    .click()


    will attach my event to all existing and future elements that match the selector.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •