Thanks so much Ricardo and MorningZ ! I think I have a good
understanding now.
On Apr 22, 7:11 pm, MorningZ morni...@gmail.com wrote:
In the example provided on the page I was viewing,
$(a).filter(.clickme).click(function(){ alert(You are now
leaving the site.); }).end()
can you
Say you have the html of
div
spanOne/span
spanTwo/span
spanThree/span
/div
and say:
var $obj = $(div);
your jQuery object, $obj, will be just the div tag
Now if you say
var $obj = $(div).find(span);
that would first be an object representing the div and the .find()
makes it be
you help me understand .end() ?
Say you have the html of
div
spanOne/span
spanTwo/span
spanThree/span
/div
and say:
var $obj = $(div);
your jQuery object, $obj, will be just the div tag
Now if you say
var $obj = $(div).find(span);
that would first be an object representing the div
-Original Message-
From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
Behalf Of MorningZ
Sent: Wednesday, April 22, 2009 1:06 PM
To: jQuery (English)
Subject: [jQuery] Re: Can you help me understand .end() ?
Say you have the html of
div
spanOne/span
if you do something like:
$(div).find(span).css('background':'red').end().css('background':'green');
spans will be red, and the divs will be green.
.end() reset the chain to the first selector
On Wed, Apr 22, 2009 at 2:05 PM, MorningZ morni...@gmail.com wrote:
Say you have the html of
MorningZ and Ignacio, Thanks so much for the examples. Both helped me
understand .end() better.
I have a couple additional questions to solidfy my understanding.
Is this example,
$(div).find(span).css('background':'red').end().css
('background':'green');
mainly where you see .end() being
In the docs example end() is not doing anything useful, it's just
showing where end() fits. I use it to avoid repeating selectors:
$('#myform')
.find('input')
.click(fn..).end()
.find('textarea')
.mouseover(fn...).end()
.find('label')
.css('color', 'red');
Limiting
In the example provided on the page I was viewing,
$(a).filter(.clickme).click(function(){ alert(You are now
leaving the site.); }).end()
can you describe what .end() is doing?
.end() is doing absolutely nothing
but at that point you are back to the collection of a's in the chain
and
8 matches
Mail list logo