开发者

Variables and jquery objects

开发者 https://www.devze.com 2023-01-05 03:13 出处:网络
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

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');
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号