开发者

Complex jquery selection that also involves custom xml tags

I want to write a select something like...

#window_4 > content > p:eq(0)

I think I have this correct, but I have a few selectors that are all similar but I can't test them all at once.

Am I right in saying this is selecting an element, who is the fist p tag child of a content tag that is a child of a tag with id 'window_4'

If I have gotten this wrong, can you give me some pointers. Would love to be able to simplify this code, I开发者_运维知识库 have more code selecting the tag I am after then actually doing stuff with them.


Looks good to me, although you can make it a bit more readable by substituting p:eq(0) for p:first.

Edit for comment:

jQuery always returns an array of elements, no matter whether 0, 1 or many elements were found. On these elements, yes, you can perform JS functions, such as innerHTML. You can access each element returned by jQuery just as if you would any other array:

$(".red")[0].innerHTML = "Glen Crawford";

More info: http://groups.google.com/group/jquery-ui/browse_thread/thread/34551a757f139ae1/20111f82c2596426

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜