ITeye博客

jquery css选择符

luocb1980 · 2012-12-11 21:58 · JavaScript · jquery · Web前端 · Markdown

1.顶级目录: $(document).ready(function() { $('#id > li').addClass('horizontal'); }); ***查找ID为id的元素的子元素(>)中的所有项(li).

horizontal由css编辑: .horizontal { float: left; list-style: none; margin: 10px; }

  1. 否定式 $(document).ready(function() { #('#id li:not(.horizontal)').addClass('sub-level'); }); ***查找ID为id的元素的所有后代元素li,没有horizontal的类。

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。