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,
> $('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
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
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('
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
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:
>
$('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
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
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:
>
>
9 matches
Mail list logo