Did you try next("span")?

Glen

On 7/9/07, jmbJq <[EMAIL PROTECTED]> wrote:


Been using jQuery for a while, but can't seem to figure this one out.
What I want to do is get the next span element when someone clicks on
the text inside the first span element.  Then when someone clicks on
the text in the second span element, get the next span, and so on.  If
someone clicks on the last span, it should not select any further span
elements (i.e. it should not wrap back around to the first span). I've
posted an example below.

I've tried using the .next() function, but that only returns the very
next element.  I've also tried using .siblings(), but that gives me
all of the siblings that are spans, not just the next one.  One thing
to keep in mind is that the actual page I am doing this on will have
hundreds of these div sections, so accessing spans by ID is not
useful.  It needs to be able to programmatically find the next sibling
span.


<html>
<head>
<title>TEST</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-
latest.pack.js"></script>
<script language="JavaScript">
$(function()
  {
      $('#span1').bind('click', function()
                                {
                                    // GET THE NEXT SPAN HERE
                                });
  });
</script>
</head>
<body>

<div id="div1">
  <span id="span1">SOME TEXT</span><br />
  <a href="http://www.google.com";>GOOGLE</a><br />
  <span>MORE TEXT</span><br />
  <div><textarea name=""></textarea></div>
  <span>A LITTLE MORE TEXT</span>
</div>

</body>
</html>


Reply via email to