开发者

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜