开发者

Can one use a class to define a jQuery child selector?

I saw this example used here and I am wondering if it can be modified to use a class instead of an ID. The reason for this is that I would like to use this script in conju开发者_运维问答nction with WordPress.

$(".anyclass ul li:last-child").addClass("no-border");

If it will help I can post the php generated html code from WordPress.


Yes, you can do this. It will be less efficient than using an ID selector, but will work fine. If you can, it would be good to optimise the selection by giving the tagname:

$('div.anyclass ul li:last-child').addClass('no-border');
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜