Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
  1. #1
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    Ok, so what I'm trying to do is:
    When I hover over a <li> in an image carousel I made, I want an information panel (".label") to fill with information from a <p> within that <li>. Here's the basic structure of the HTML:
    HTML Code:
    <div class="gallery">
      <ul>
        <li>
          <img ... />
          <p>Information</p>
        </li>
        <!-- Repeat li -->
      </ul>
      <div class="label"></div>
    </div>
    And here's the jQuery I've written:
    Code:
    $('.gallery ul > li').hover(
            function(){
                $('.label').html($(this).children('p')).fadeIn('fast');
            },
            function(){
                $('.label').fadeOut('fast');
            }
        );
    Now, everything works just fine, but only the first time you hover over each <li>. After that, it only fades in the <div>, but there's no HTML. I suspect it has to do with the use of "this" in the 3rd line, but I'm not sure and if it does I have no idea how else to do it.
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  2.  

  3. #2
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    $(this).children('p').html()
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  4. #3
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    I'm trying to pull HTML from the <p> into the div. Slap me if I'm wrong, but I don't think that'd do it.
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  5. #4
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    So you want the p tag itself as well?

    $(this).children.eq(1) maybe.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  6. #5
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    I don't need the tag itself. I guess I'm having a hard time explaining what I need. Each <li> has an image and a paragraph. The paragraph is hidden. It's in the <li> to keep them grouped together and more easily selectable. There is a div after the list. What I'm trying to do is use JS to insert the contents of the paragraph into the div that's after the list when the list item is hovered.

    All of that works, but only the first time you hover each <li>. Each subsequent time you hover the <li>, the div shows, but is empty.
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  7. #6
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    Illustration. What I need is for blocks 1 & 2 in the below image to be the only states. However, once you've hovered once, subsequent hovers look like block 3 in the image.
    Attachment 2614
    I have something in place that's adequate for now, and since this is a personal project, that's ok. However, I'd really like to figure this out if anyone has any ideas on why it isn't working properly. I'm getting much better with JS, but I wouldn't even know how to begin troubleshooting something like this.
    Attached Images Attached Images
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  8. #7
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    I'd have to see the code in action, dude. I got nothing otherwise. It looks like it should work.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  9. #8
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    Sent you a PM.
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  10. #9
    WDF Staff AlphaMare's Avatar
    Join Date
    Oct 2009
    Location
    Montreal, Canada
    Posts
    4,570
    Member #
    20277
    Liked
    878 times
    Quote Originally Posted by Ronald Roe, post: 243603
    Illustration. What I need is for blocks 1 & 2 in the below image to be the only states. However, once you've hovered once, subsequent hovers look like block 3 in the image.
    hovers.png
    I have something in place that's adequate for now, and since this is a personal project, that's ok. However, I'd really like to figure this out if anyone has any ideas on why it isn't working properly. I'm getting much better with JS, but I wouldn't even know how to begin troubleshooting something like this.
    Try giving each p tag a class, and call the class in the javascript.
    If you just call the p tag, it will only show your first p, since then the conditions of the script are met.
    You could adapt something from this - http://www.brightcherry.co.uk/scribb...-next-element/
    Good design should never say "Look at me!"
    It should say "Look at this." ~ David Craib


    http://digitalinsite.ca ~ my current site . . info@digitalinsite.ca ~ my email

    If you feel that someone's post helped you fix your problem, answered your question, or just made you feel better, feel free to "Like" their post. The "Like" link is at the bottom right of each post, along side the "reply" link. And if you are being helped here, try to help someone else - pass it on!

  11. #10
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    As it turns out, .html() removes the original p, so it isn't there to insert into the div. I haven't had a chance to work on the new solution, for which I have a suggestion, but that's what the problem is.
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

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

Search tags for this page

jquery populater div

Click on a term to search for related topics.
All times are GMT -6. The time now is 01:27 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com