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.

Results 1 to 2 of 2
  1. #1
    Junior Member Mahzian's Avatar
    Join Date
    Jan 2009
    Location
    Brisbane, Australia
    Posts
    1
    Member #
    18176
    Hi guys, been trying to wrap my head around this for a few hours and thought someone might be able to help me solve this problem. What I'm trying to do is have a bunch of links, each of which "show" a div that sits under it but all of them using the same code (I found out the $(this) feature might be the best way to do this, but I'm having trouble when it comes to showing the div when it isn't directly under the link.
    I can can get it to work with the following jquery/html:
    Code:
    $('#tester').hide();
      $('.editattempt').click (function() {
      $(this).parent().next('.attempt').show();
      return false;
     });
    Code:
    <div>attempt 1(<a href="" class="editattempt">add next attempt</a>)</div>
    <div id="tester" class="attempt">attempt 2</div>
    <div class="blah">blah blah blah</div>
    But when I move the "blah" div between the link's div and the "attempt" div it doesnt work.
    Code:
    <div>attempt 1(<a href="" class="editattempt">add next attempt</a>)</div>
    <div class="blah">blah blah blah</div>
    <div id="tester" class="attempt">attempt 2</div>
    I'm guessing I might have to use .find(), anyone have any ideas?

    Thanks in advance!

  2.  

  3. #2
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Been a while since you asked this question, but you probably want .nextAll('.attempt'). Trouble is that if there are multiple such attempt divs that are subsequent siblings, you're in trouble. At which point, you may be able to do .nextAll('.attempt').slice(0,1) to grab the first one and then hide that.


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
  •  
All times are GMT -6. The time now is 12:12 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com