代码例子:某个div块下的字体样式的控制。

View Code
第一种:jquery条件综合多条件选择器
模式:$(选择器1,选择器2)----->返回选择器1内符合选择器2的jquery对象(选择器1内的后代元素,儿子孙子辈都有)
第二种:jquery对象find()方法
模式:$(选择器1,选择器2).find("选择器3")--->返回符合选择器1,选择器2的jquery对象中包含的符合选择器3的所有后代元素。包括孙子辈。不包括自身。
第三种:jquery对象children()方法
模式:$(选择器1,选择器2).children("选择器3")--->返回符合选择器1+选择器2的孩子级别的选择器3的jquery对象。只包含孩子辈,无孙子辈。不包括自身。
选择器
实例
选取
<a href="http://www.w3school.com.cn/jquery/selector_all.asp">*</a>
$("*")
所有元素
<a href="http://www.w3school.com.cn/jquery/selector_id.asp">#id</a>
$("#lastname")
id="lastname" 的元素
<a href="http://www.w3school.com.cn/jquery/selector_class.asp">.class</a>
$(".intro")
所有 class="intro" 的元素
<a href="http://www.w3school.com.cn/jquery/selector_element.asp">element</a>
$("p")
所有 <p> 元素
.class.class
$(".intro.demo")
所有 class="intro" 且 class="demo" 的元素
<a href="http://www.w3school.com.cn/jquery/selector_first.asp">:first</a>
$("p:first")
第一个 <p> 元素
<a href="http://www.w3school.com.cn/jquery/selector_last.asp">:last</a>
$("p:last")
最后一个 <p> 元素
<a href="http://www.w3school.com.cn/jquery/selector_even.asp">:even</a>
$("tr:even")
所有偶数 <tr> 元素
<a href="http://www.w3school.com.cn/jquery/selector_odd.asp">:odd</a>
$("tr:odd")
所有奇数 <tr> 元素
<a href="http://www.w3school.com.cn/jquery/selector_eq.asp">:eq(index)</a>
$("ul li:eq(3)")
列表中的第四个元素(index 从 0 开始)
<a href="http://www.w3school.com.cn/jquery/selector_gt.asp">:gt(no)</a>
$("ul li:gt(3)")
列出 index 大于 3 的元素
<a href="http://www.w3school.com.cn/jquery/selector_lt.asp">:lt(no)</a>
$("ul li:lt(3)")
列出 index 小于 3 的元素
:not(selector)
$("input:not(:empty)")
所有不为空的 input 元素
<a href="http://www.w3school.com.cn/jquery/selector_header.asp">:header</a>
$(":header")
所有标题元素 <h1> - <h6>
<a href="http://www.w3school.com.cn/jquery/selector_animated.asp">:animated</a>
所有动画元素
<a href="http://www.w3school.com.cn/jquery/selector_contains.asp">:contains(text)</a>
$(":contains('W3School')")
包含指定字符串的所有元素
<a href="http://www.w3school.com.cn/jquery/selector_empty.asp">:empty</a>
$(":empty")
无子(元素)节点的所有元素
:hidden
$("p:hidden")
所有隐藏的 <p> 元素
<a href="http://www.w3school.com.cn/jquery/selector_visible.asp">:visible</a>
$("table:visible")
所有可见的表格
s1,s2,s3
$("th,td,.intro")
所有带有匹配选择的元素
<a href="http://www.w3school.com.cn/jquery/selector_attribute.asp">[attribute]</a>
$("[href]")
所有带有 href 属性的元素
<a href="http://www.w3school.com.cn/jquery/selector_attribute_equal_value.asp">[attribute=value]</a>
$("[href='#']")
所有 href 属性的值等于 "#" 的元素
<a href="http://www.w3school.com.cn/jquery/selector_attribute_notequal_value.asp">[attribute!=value]</a>
$("[href!='#']")
所有 href 属性的值不等于 "#" 的元素
<a title="jQuery [attribute$=value] 选择器" href="http://www.w3school.com.cn/jquery/selector_attribute_end_value.asp">[attribute$=value]</a>
$("[href$='.jpg']")
所有 href 属性的值包含以 ".jpg" 结尾的元素
<a href="http://www.w3school.com.cn/jquery/selector_input.asp">:input</a>
$(":input")
所有 <input> 元素
<a href="http://www.w3school.com.cn/jquery/selector_input_text.asp">:text</a>
$(":text")
所有 type="text" 的 <input> 元素
<a href="http://www.w3school.com.cn/jquery/selector_input_password.asp">:password</a>
$(":password")
所有 type="password" 的 <input> 元素
<a href="http://www.w3school.com.cn/jquery/selector_input_radio.asp">:radio</a>
$(":radio")
所有 type="radio" 的 <input> 元素
<a href="http://www.w3school.com.cn/jquery/selector_input_checkbox.asp">:checkbox</a>
$(":checkbox")
所有 type="checkbox" 的 <input> 元素
<a href="http://www.w3school.com.cn/jquery/selector_input_submit.asp">:submit</a>
$(":submit")
所有 type="submit" 的 <input> 元素
<a href="http://www.w3school.com.cn/jquery/selector_input_reset.asp">:reset</a>
$(":reset")
所有 type="reset" 的 <input> 元素
<a href="http://www.w3school.com.cn/jquery/selector_input_button.asp">:button</a>
$(":button")
所有 type="button" 的 <input> 元素
<a href="http://www.w3school.com.cn/jquery/selector_input_image.asp">:image</a>
$(":image")
所有 type="image" 的 <input> 元素
<a href="http://www.w3school.com.cn/jquery/selector_input_file.asp">:file</a>
$(":file")
所有 type="file" 的 <input> 元素
<a href="http://www.w3school.com.cn/jquery/selector_input_enabled.asp">:enabled</a>
$(":enabled")
所有激活的 input 元素
<a href="http://www.w3school.com.cn/jquery/selector_input_disabled.asp">:disabled</a>
$(":disabled")
所有禁用的 input 元素
<a href="http://www.w3school.com.cn/jquery/selector_input_selected.asp">:selected</a>
$(":selected")
所有被选取的 input 元素
<a href="http://www.w3school.com.cn/jquery/selector_input_checked.asp">:checked</a>
$(":checked")
所有被选中的 input 元素
撒旦法