Variables and jquery objects
I am using variables to hold jquery objects as
$mydiv = $('#somediv');
Now I would like to extend this to reference a paragraph within $mydiv
. Obviously you could declare a new variable
$mypar开发者_JAVA技巧a = $('#somediv p')
But is there any way to extend the $mydiv
variable to find the paragraph it contains.
I just can't figure out the right notation to do this.
This should do it:
$mydiv.find('p');
You can use:
var = mydiv = $('#somediv');
var children = mydiv.children('p');
This will give you all the child 'p' elements belonging to your div.
Yes.It have.
$mydiv = $('#somediv');
$mydiv.find('p');
精彩评论