Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-29-2009, 10:05 PM   PM User | #1
sethwb
Regular Coder

 
Join Date: Aug 2008
Posts: 105
Thanks: 9
Thanked 0 Times in 0 Posts
sethwb is an unknown quantity at this point
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?
sethwb is offline   Reply With Quote
Old 09-29-2009, 10:50 PM   PM User | #2
sethwb
Regular Coder

 
Join Date: Aug 2008
Posts: 105
Thanks: 9
Thanked 0 Times in 0 Posts
sethwb is an unknown quantity at this point
I found the solution:


live("click", function()


instead of

.click()


will attach my event to all existing and future elements that match the selector.
sethwb is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:43 AM.


Advertisement
Log in to turn off these ads.