[jQuery] Re: Selecting subsequent siblings

2007-09-03 Thread David Duymelinck
Erik Beeson schreef: $('div').each(function(){ var id= $(this).attr('id'); $('span').each(function(){ if(id = $(this).attr('class')){ alert($(this).text()); } }); }); That attr('class') bit will get you in to trouble. I suggest using .is(), and in fact,

[jQuery] Re: Selecting subsequent siblings

2007-09-03 Thread Erik Beeson
> $('div').each(function(){ > var id= $(this).attr('id'); > $('span').each(function(){ >if(id = $(this).attr('class')){ > alert($(this).text()); >} > }); > }); That attr('class') bit will get you in to trouble. I suggest using .is(), and in fact, if you know

[jQuery] Re: Selecting subsequent siblings

2007-09-03 Thread George
Using your "myclass" example, the enhanced .siblings() method might be used like this: $("DIV").siblings("SPAN.myclass:first", false, "next") Not ethat this will return all the SPANs with classname "myclass" that follow all the DIVs, so as it stands it it probably no different from the standard

[jQuery] Re: Selecting subsequent siblings

2007-09-03 Thread David Duymelinck
You need a hook somewhere to base your selection upon and i thought it was the text of the div and the span. If you use the id of the div and the classname of the span you can do $('div').each(function(){ var id= $(this).attr('id'); $('span').each(function(){ if(id = $(this).attr('

[jQuery] Re: Selecting subsequent siblings

2007-09-03 Thread George
My moreSelectors plugin has an undocumented feature that enhances the .siblings() method to optionally return preceeding or following siblings only. Syntax: $(...).siblings(expr, self, prevOrNext) Specify self as true to retain the current element(s) in the results. (default is false so that exis

[jQuery] Re: Selecting subsequent siblings

2007-09-03 Thread ronnie98
Thank you david, but i cannot base my selection on the text/html of the element. I only put it in the sample to make things a bit clear. What if i added a class to the span to be selected ex: first second ? DavidIcreate wrote: >

[jQuery] Re: Selecting subsequent siblings

2007-09-03 Thread David Duymelinck
$('div').each(function(){ var text = $(this).text(); $('span').each(function(){ if(text == $(this).text()){ alert('found '+text); } }); }); This code will not get you the subsequent siblings but it will get you the span with the same content as the div. I

[jQuery] Re: Selecting subsequent siblings

2007-09-03 Thread ronnie98
Your code didn't come through very well, but maybe you want next()? http://docs.jquery.com/Traversing/next#expr --Erik Thank you erik but next() is not suitable since (as from the above example) it selects the first (empty) "span" -- View this message in context: http://www.nabble.com/Sel

[jQuery] Re: Selecting subsequent siblings

2007-09-03 Thread Erik Beeson
Your code didn't come through very well, but maybe you want next()? http://docs.jquery.com/Traversing/next#expr --Erik On 9/2/07, ronnie98 <[EMAIL PROTECTED]> wrote: > > > > Hi all, > i have troubles with subsequent siblings selection. > Provided the following code: > >