<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>╭╰Original　Colors╯╮ - 认真工作 &#187; 使用方法</title>
	<atom:link href="http://www.iros.me/tag/%e4%bd%bf%e7%94%a8%e6%96%b9%e6%b3%95/feed" rel="self" type="application/rss+xml" />
	<link>http://www.iros.me</link>
	<description>show the colorsssssss in my WORK</description>
	<lastBuildDate>Fri, 09 Sep 2011 06:29:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>[转载] jQuery Selectors 选择器的使用</title>
		<link>http://www.iros.me/jquery-selectors.html</link>
		<comments>http://www.iros.me/jquery-selectors.html#comments</comments>
		<pubDate>Thu, 15 Jan 2009 08:30:23 +0000</pubDate>
		<dc:creator>ponytail</dc:creator>
				<category><![CDATA[┨Stuuuuuuuudy]]></category>
		<category><![CDATA[Jquery Selectors]]></category>
		<category><![CDATA[使用方法]]></category>
		<category><![CDATA[选择器]]></category>

		<guid isPermaLink="false">http://www.originalcolors.cn/work/?p=370</guid>
		<description><![CDATA[jQuery的选择器是CSS 1-3，XPath的结合物。jQuery提取这二种查询语言最好的部分，融合后创造出了最终的jQuery表达式查询语言。如果你了解CSS（绝大部分WEB开发者都用到的），那么你学起来就很容易了。 同时使用CSS和XPath 看几个例子： 隐藏所有包含有链接的段落： $(&#8220;p[a]&#8220;).hide(); 显示页面的第一个段落： $(&#8220;p:eq(0)&#8221;).show(); 隐藏所有当前可见的层元素： $(&#8220;div:visible&#8221;).hide(); 获取所有无序列表的列表项： $(&#8220;ul/li&#8221;) /* valid too: $(&#8220;ul &#62; li&#8221;) */ 取得name值为bar的输入字段的值： $(&#8220;input[@name=bar]&#8220;).val(); 所有处于选中状态的单选r按钮： $(&#8220;input[@type=radio][@checked]&#8220;) 如果你对查询语言的工作原理还有疑问，可以订阅这里的邮件列表。 CSS查询器 jQuery完全支持CSS1.3。 关于CSS的一些资料查看下面的连接： CSS 1 CSS 2 CSS 3 下面列出来的是支持的CSS查询器的列表式语法： * 任何元素 E 类型为E的元素 E:root 类型为E，并且是文档的根元素 E:nth-child(n) 是其父元素的第n个类型为E的子元素 E:first-child 是其父元素的第1个类型为E的子元素 E:last-child 是其父元素的最后一个类型为E的子元素 E:only-child 且是其父元素的唯一一个类型为E的子元素 E:empty 没有子元素（包括text节点）的类型为E的元素 E:enabled E:disabled 类型为E，允许或被禁止的用户界面元素 E:checked 类型为E，处于选中状态的用户界面元素（例如单选按钮或复选框） [...]<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.iros.me%2Fjquery-methods.html&from=http%3A%2F%2Fwww.iros.me%2Fjquery-selectors.html">
                        <font size="-1" color="#666666" style="line-height: 1.65em; font-size: 12px !important;">jQuery 常用方法一览</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.iros.me%2Fladeqit-learning-jquery-animate.html&from=http%3A%2F%2Fwww.iros.me%2Fjquery-selectors.html">
                        <font size="-1" color="#666666" style="line-height: 1.65em; font-size: 12px !important;">ladeq.it 学习Jquery animate方法，这个是WP居然</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.iros.me%2Flight-box-effect-js-collection-jquery-related.html&from=http%3A%2F%2Fwww.iros.me%2Fjquery-selectors.html">
                        <font size="-1" color="#666666" style="line-height: 1.65em; font-size: 12px !important;">LIGHT BOX效果JS大集合（Jquery相关）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.iros.me%2Fbest-jquery-plugins-of-2010.html&from=http%3A%2F%2Fwww.iros.me%2Fjquery-selectors.html">
                        <font size="-1" color="#666666" style="line-height: 1.65em; font-size: 12px !important;">Best jQuery Plugins of 2010</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>jQuery的选择器是CSS 1-3，XPath的结合物。jQuery提取这二种查询语言最好的部分，融合后创造出了最终的jQuery表达式查询语言。如果你了解CSS（绝大部分WEB开发者都用到的），那么你学起来就很容易了。</p>
<p><strong>同时使用CSS和XPath</strong></p>
<p>看几个例子：</p>
<p>隐藏所有包含有链接的段落：</p>
<p>$(&#8220;p[a]&#8220;).hide();</p>
<p><span id="more-370" ></span>显示页面的第一个段落：</p>
<p>$(&#8220;p:eq(0)&#8221;).show();</p>
<p>隐藏所有当前可见的层元素：</p>
<p>$(&#8220;div:visible&#8221;).hide();</p>
<p>获取所有无序列表的列表项：</p>
<p>$(&#8220;ul/li&#8221;)</p>
<p>/* valid too: $(&#8220;ul &gt; li&#8221;) */</p>
<p>取得name值为bar的输入字段的值：</p>
<p>$(&#8220;input[@name=bar]&#8220;).val();</p>
<p>所有处于选中状态的单选r按钮：</p>
<p>$(&#8220;input[@type=radio][@checked]&#8220;)</p>
<p>如果你对查询语言的工作原理还有疑问，可以<a  href="http://jquery.com/discuss/" target="_blank">订阅这里的邮件列表</a>。</p>
<p><strong>CSS查询器</strong></p>
<p>jQuery完全支持CSS1.3。</p>
<p>关于CSS的一些资料查看下面的连接：</p>
<ul>
<li><a  href="http://www.w3.org/TR/REC-CSS1#basic-concepts">CSS 1</a></li>
<li><a  href="http://www.w3.org/TR/REC-CSS2/selector.html">CSS 2</a></li>
<li><a  href="http://www.w3.org/TR/2005/WD-css3-selectors-20051215/">CSS 3</a></li>
</ul>
<p>下面列出来的是支持的CSS查询器的列表式语法：</p>
<ul>
<li>* 任何元素</li>
<li><strong>E</strong> 类型为E的元素</li>
<li><strong>E</strong>:root 类型为E，并且是文档的根元素</li>
<li><strong>E:nth-child(n)</strong> 是其父元素的第n个类型为E的子元素</li>
<li><strong>E:first-child </strong>是其父元素的第1个类型为E的子元素</li>
<li><strong>E:last-child</strong> 是其父元素的最后一个类型为E的子元素</li>
<li><strong>E:only-child</strong> 且是其父元素的唯一一个类型为E的子元素</li>
<li><strong>E:empty</strong> 没有子元素（包括text节点）的类型为E的元素</li>
<li><strong>E:enabled</strong></li>
<li><strong>E:disabled</strong> 类型为E，允许或被禁止的用户界面元素</li>
<li><strong>E:checked</strong> 类型为E，处于选中状态的用户界面元素（例如单选按钮或复选框）</li>
<li><strong>E.warning</strong> 类型为E，且class属性值为warning</li>
<li><strong>E#myid</strong> 类型为E，ID为 &#8220;myid&#8221;。（至多匹配一个元素）</li>
<li><strong>E:not(s)</strong> 类型为E，不匹配选择器s</li>
<li><strong>E F</strong> 在类型E后面的类型为F的元素</li>
<li><strong>E &gt; F</strong> 为E元素子元素的F元素</li>
<li><strong>E + F</strong> an F element immediately preceded by an E element</li>
<li><strong>E ~ F</strong> an F element preceded by an E element</li>
</ul>
<p><strong>不同之处</strong></p>
<p>所有的属性选择器都被写成和XPath极其相似（因为所有的属性都以@符号开始）。</p>
<ul>
<li><strong>E[@foo]</strong> 拥有foo属性的E元素</li>
<li><strong>E[@foo=bar]</strong> foo属性的值为bar的E元素</li>
<li><strong>E[@foo^=bar]</strong> foo属性的值以字符串&#8221;bar&#8221;开始的E元素</li>
<li><strong>E[@foo$=bar]</strong> foo属性的值以字符串&#8221;bar&#8221;结尾的E元素</li>
<li><strong>E[@foo*=bar]</strong> foo属性的值包含有字符串&#8221;bar&#8221;结尾的E元素</li>
</ul>
<p><strong>不支持的部分</strong></p>
<ul>
<li><strong>E:link</strong></li>
<li><strong>E:visited</strong> an E element being the source anchor of a hyperlink of which the target is not yet visited (:link) or already visited (:visited)</li>
<li><strong>E:active</strong></li>
<li><strong>E:hover</strong></li>
<li><strong>E:focus</strong> an E element during certain user actions</li>
<li><strong>E:target</strong> an E element being the target of the referring URI</li>
<li><strong>E::first-line</strong> the first formatted line of an E element</li>
<li><strong>E::first-letter</strong> the first formatted letter of an E element</li>
<li><strong>E::selection</strong> the portion of an E element that is currently selected/highlighted by the user</li>
<li><strong>E::before</strong> generated content before an E element</li>
<li><strong>E::after</strong> generated content after an E element</li>
</ul>
<p>jQuery不支持下列的选择器，因为这些没什么用处。</p>
<ul>
<li><strong>E:nth-last-child(n)</strong> an E element, the n-th child of its parent, counting from the last one</li>
<li><strong>E:nth-of-type(n)</strong> an E element, the n-th sibling of its type</li>
<li><strong>E:nth-last-of-type(n)</strong> an E element, the n-th sibling of its type, counting from the last one</li>
<li><strong>E:first-of-type</strong> an E element, first sibling of its type</li>
<li><strong>E:last-of-type</strong> an E element, last sibling of its type</li>
<li><strong>E:only-of-type</strong> an E element, only sibling of its type</li>
<li><strong>E:lang(fr)</strong> an element of type E in language &#8220;fr&#8221;</li>
</ul>
<p><strong>XPath 查询器</strong></p>
<p>XPath是jQuery内置支持的一种表达式语言。jQuery支持基本的<a  href="http://www.w3.org/TR/xpath">XPath表达</a>式。</p>
<p><strong>定位路径</strong></p>
<ul>
<li>绝对路径<br/>
$(&#8220;/html/body//p&#8221;)<br/>
$(&#8220;/*/body//p&#8221;)<br/>
$(&#8220;//p/../div&#8221;)</li>
<li>相对路径<br/>
$(&#8220;a&#8221;,this)<br/>
$(&#8220;p/a&#8221;,this)</li>
</ul>
<pre><strong>支持的Axis选择器</strong></pre>
<ul>
<li><strong>Descendant</strong> Element has a descendant element</li>
</ul>
<pre> $("//div//p")</pre>
<ul>
<li><strong>Child</strong> Element has a child element</li>
</ul>
<pre> $("//div/p")</pre>
<ul>
<li><strong>Preceding Sibling</strong> Element has an element before it, on the same axes</li>
</ul>
<pre> $("//div ~ form")</pre>
<ul>
<li><strong>Parent</strong> Selects the parent element of the element</li>
</ul>
<pre> $("//div/../p")
<strong>支持的谓词</strong></pre>
<ul>
<li><strong>[@*]</strong> 拥有一个属性<br/>
$(&#8220;//div[@*]&#8220;)</li>
<li><strong>[@foo]</strong> 拥有foo属性<br/>
$(&#8220;//input[@checked]&#8220;)</li>
<li><strong>[@foo='test']</strong> 属性foo值为&#8217;test&#8217;<br/>
$(&#8220;//a[@ref='nofollow']&#8220;)</li>
<li><strong>[Nodelist]</strong> Element contains a node list, for example:<br/>
$(&#8220;//div[p]&#8220;)<br/>
$(&#8220;//div[p/a]&#8220;)</li>
</ul>
<p>支持的谓词，但与XPath和CSS又不同的</p>
<ul>
<li><strong>[last()] or [position()=last()]</strong>改为<strong>:last<br/>
</strong>$(&#8220;p:last&#8221;)</li>
<li><strong>[0] or [position()=0]</strong> 改为 <strong>:eq(0) or :first<br/>
</strong>$(&#8220;p:first&#8221;)<br/>
$(&#8220;p:eq(0)&#8221;)</li>
<li><strong>[position() &lt; 5]</strong> 改为<strong>:lt(5)<br/>
</strong>$(&#8220;p:lt(5)&#8221;)</li>
<li><strong>[position() &gt; 2]</strong> 改为<strong>:gt(2)<br/>
</strong>$(&#8220;p:gt(2)&#8221;)</li>
</ul>
<p><strong>定制的选择器</strong></p>
<p>jQuery包含一些在CSS和XPath都不用到的表达式，但我们觉得它们使用起来非常方便，所以包含进来了。</p>
<p>下列的列表式语法基于不同的CSS选择器，但又有非常相似的名字。</p>
<ul>
<li><strong>:even</strong> 从匹配的元素集中取序数为偶数的元素</li>
<li><strong>:odd</strong> 从匹配的元素集中取序数为奇数的元素</li>
<li><strong>:eq(0) and :nth(0)</strong> 从匹配的元素集中取第0个元素</li>
<li><strong>:gt(4)</strong> 从匹配的元素集中取序数大于N的元素</li>
<li><strong>:lt(4)</strong> 从匹配的元素集中取序数小于N的元素</li>
<li><strong>:first</strong> 相当于 <strong>:eq(0)</strong></li>
<li><strong>:last</strong> 最后一个匹配的元素</li>
<li><strong>:parent</strong> 选择包含子元素（包含text节点）的所有元素</li>
<li><strong>:contains(&#8216;test&#8217;)</strong> 选择所有含有指定文本的元素</li>
<li><strong>:visible</strong> 选择所有可见的元素（display值为block 或者visible 、visibility 值为visible的元素，不包括hide域）</li>
<li><strong>:hidden</strong> 选择所有隐藏的元素(非Hide域，且display值为block 或者visible 、visibility 值为visible的元素)</li>
</ul>
<p>例：</p>
<pre> $("p:first").css("fontWeight","bold");
$("div:hidden").show();
$("div:contains('test')").hide();</pre>
<p><strong>表单选择器<br/>
</strong>这是为表单提供的一些选择器：</p>
<ul>
<li><strong>:input</strong> 选择表单元素（input, select, textarea, button）</li>
<li><strong>:text</strong> 选择所有文本域(type=&#8221;text&#8221;)</li>
<li><strong>:password</strong> 选择所有密码域(type=&#8221;password&#8221;).</li>
<li><strong>:radio</strong> 选择所有单选按钮(type=&#8221;radio&#8221;).</li>
<li><strong>:checkbox</strong> 选择所有复选框(type=&#8221;checkbox&#8221;).</li>
<li><strong>:submit</strong> 选择所有提交按钮(type=&#8221;submit&#8221;).</li>
<li><strong>:image</strong> 选择所有图像域 (type=&#8221;image&#8221;).</li>
<li><strong>:reset</strong> 选择所有清除域(type=&#8221;reset&#8221;).</li>
<li><strong>:button</strong> 选择所有按钮(type=&#8221;button&#8221;).</li>
</ul>
<p>同样也可以使用:hidden，详细说明上面已经介绍过。</p>
<p>$(&#8216;#myForm :input&#8217;)</p>
<p>如果你需要指定表单：</p>
<p>$(&#8216;input:radio&#8217;, myForm)</p>
<p>这将选择myForm表单中所有单选按钮。选择radio通常是用[@type=radio]，但是这样用理精简些。</p>
<p><strong>更多的选择器</strong></p>
<p>jQuery选择器可以用一些第三方部件进行扩充：</p>
<ul>
<li><a  href="http://www.softwareunity.com/sandbox/JQueryMoreSelectors/">More Selectors Plugin</a></li>
<li><a  href="http://www.malsup.com/jquery/expr/">Mike Alsup on Custom Selectors</a></li>
<li><a  href="http://jquery.com/dev/bugs/bug/312/">Patch</a> to allow selection by CSS property (full plugin to be released simultaneously with 1.1)</li>
</ul>
<blockquote><p>无常翻译：<a  href="http://wuchang.cnblogs.com/">wuchang.cn</a><br/>
<a  href="mailto:wuChang@guet.edu.cn">wuChang@guet.edu</a><br/>
QQ: 3263262</p>
<p>Retrieved from &#8220;<a  href="http://www.docs.jquery.com/DOM/Traversing/Selectors">www.docs.jquery.com</a>&#8220;</p></blockquote>
<table class="wumii-related-items"  cellspacing="0"  cellpadding="2"  border="0"  width="100%"  style="clear: both;" >
    
    <tr>
        <td><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;" >您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;" >
                    <img border="0"  src="http://static.wumii.com/images/widget/widget_solidPoint.gif" />
                    <a  target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.iros.me%2Fjquery-methods.html&#038;from=http%3A%2F%2Fwww.iros.me%2Fjquery-selectors.html">
                        <font size="-1"  color="#666666"  style="line-height: 1.65em; font-size: 12px !important;" >jQuery 常用方法一览</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;" >
                    <img border="0"  src="http://static.wumii.com/images/widget/widget_solidPoint.gif" />
                    <a  target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.iros.me%2Fladeqit-learning-jquery-animate.html&#038;from=http%3A%2F%2Fwww.iros.me%2Fjquery-selectors.html">
                        <font size="-1"  color="#666666"  style="line-height: 1.65em; font-size: 12px !important;" >ladeq.it 学习Jquery animate方法，这个是WP居然</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;" >
                    <img border="0"  src="http://static.wumii.com/images/widget/widget_solidPoint.gif" />
                    <a  target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.iros.me%2Flight-box-effect-js-collection-jquery-related.html&#038;from=http%3A%2F%2Fwww.iros.me%2Fjquery-selectors.html">
                        <font size="-1"  color="#666666"  style="line-height: 1.65em; font-size: 12px !important;" >LIGHT BOX效果JS大集合（Jquery相关）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;" >
                    <img border="0"  src="http://static.wumii.com/images/widget/widget_solidPoint.gif" />
                    <a  target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.iros.me%2Fbest-jquery-plugins-of-2010.html&#038;from=http%3A%2F%2Fwww.iros.me%2Fjquery-selectors.html">
                        <font size="-1"  color="#666666"  style="line-height: 1.65em; font-size: 12px !important;" >Best jQuery Plugins of 2010</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td align="right" >
            <a  style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1"  color="#bbbbbb"  style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;" >无觅</font>
            </a>
        </td>
    </tr>
</table>
	标签：<a href="http://www.iros.me/tag/jquery-selectors" title="Jquery Selectors" rel="tag">Jquery Selectors</a>, <a href="http://www.iros.me/tag/%e4%bd%bf%e7%94%a8%e6%96%b9%e6%b3%95" title="使用方法" rel="tag">使用方法</a>, <a href="http://www.iros.me/tag/%e9%80%89%e6%8b%a9%e5%99%a8" title="选择器" rel="tag">选择器</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.iros.me/jquery-selectors.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

