SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Feb 2011
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problems implementing a jQuery toggle plug-in

    I've just started trying jQuery for a project and have an odd problem. A simple "toggle" to make lines of text appear/disappear works great. But, for some reason I cannot figure out, the text that triggers it shows up twice on the page. I've even tried looking for errors with Firebug and Lint but they say it's clean. Can someone take a peek at this?

    http://www.keithpurtell.com/kthings/art/test2.htm

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,175
    Mentioned
    454 Post(s)
    Tagged
    8 Thread(s)
    Which is the text that triggers a toggle?

  3. #3
    SitePoint Addict
    Join Date
    Dec 2005
    Posts
    336
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    @ralph.m: Painting detail - from the source

    @okieman - Remove/Comment this line and it should be ok:
    Code:
    $('#pane').before('<p id="x-toggle">Painting detail:</p>');

  4. #4
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,175
    Mentioned
    454 Post(s)
    Tagged
    8 Thread(s)
    Ah yes, thanks centered effect. I must be blind. Good solution, too.

  5. #5
    SitePoint Member
    Join Date
    Feb 2011
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Indeed that did solve the problem. Thank you!

    If I may borrow just a few more seconds of your time, I'd like to also try to deal with the issue that always comes up whenever someone in a forum kindly shows me correct code.

    Yes, it fixed the problem, but I'm left wondering what was the error in technique that led to the formerly-broken page? If I can learn that, I won't do it again and I won't have to be on this forum looking kinda like I don't know what I'm doing!

  6. #6
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,175
    Mentioned
    454 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by okieman View Post
    I'm left wondering what was the error in technique that led to the formerly-broken page?
    Yep, ideally the forums should be a place to learn, so ask away. In this case, it was a very simple problem: there was a line of jQuery code in there that said—"insert <p id="x-toggle">Painting detail</p> before the #pane div". But there's no need for that, since that code is already there in the HTML.


Bookmarks

Posting Permissions

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