{"id":2999,"date":"2016-01-14T14:14:11","date_gmt":"2016-01-14T06:14:11","guid":{"rendered":"https:\/\/www.ecjtu.com\/keith\/archives\/2999"},"modified":"2016-01-14T14:14:11","modified_gmt":"2016-01-14T06:14:11","slug":"jquery%e6%80%bb%e7%bb%93%e4%b8%80%ef%bc%9a%e9%80%89%e6%8b%a9%e5%99%a8%e5%bd%92%e7%ba%b3","status":"publish","type":"post","link":"https:\/\/www.ecjtu.com\/keith\/archives\/2999","title":{"rendered":"JQuery\u603b\u7ed3\u4e00\uff1a\u9009\u62e9\u5668\u5f52\u7eb3"},"content":{"rendered":"<h3 id=\"1\u57fa\u672c\u9009\u62e9\u5668\" data-anchor-id=\"x5qx\">1\u3001\u57fa\u672c\u9009\u62e9\u5668<\/h3>\n<table class=\"table table-striped-white table-bordered\" data-anchor-id=\"pmq6\">\n<thead>\n<tr>\n<th>\u9009\u62e9\u7b26<\/th>\n<th>\u5339\u914d\u5143\u7d20<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>*<\/td>\n<td>\u6240\u6709\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>id<\/td>\n<td>\u7ed9\u5b9aID\u7684\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>element<\/td>\n<td>\u7ed9\u5b9a\u7c7b\u578b\u7684\u6240\u6709\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>.class<\/td>\n<td>\u7ed9\u5b9a\u7c7b\u7684\u6240\u6709\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>a,b<\/td>\n<td>\u4e0ea\u6216b\u5339\u914d\u7684\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>a b<\/td>\n<td>a\u7684\u540e\u4ee3\u5143\u7d20\u4e2d\u4e0eb\u5339\u914d\u7684\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>a&gt;b<\/td>\n<td>a\u7684\u76f4\u63a5\u5b50\u5143\u7d20\u4e2d\u4e0eb\u5339\u914d\u7684\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>a+b<\/td>\n<td>a\u7684\u76f4\u63a5\u540c\u8f88\u5143\u7d20\u4e2d\u4e0eb\u5339\u914d\u7684\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>a~b<\/td>\n<td>a\u7684\u540c\u8f88\u5143\u7d20\u4e2d\u4e0eb\u5339\u914d\u7684\u5143\u7d20<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div class=\"md-section-divider\"><\/div>\n<h3 id=\"2\u4f4d\u7f6e\u9009\u62e9\u5668\" data-anchor-id=\"9smi\">2\u3001\u4f4d\u7f6e\u9009\u62e9\u5668<\/h3>\n<table class=\"table table-striped-white table-bordered\" data-anchor-id=\"5hq1\">\n<thead>\n<tr>\n<th>\u9009\u62e9\u7b26<\/th>\n<th>\u5339\u914d\u5143\u7d20<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>a b:nth-child(index)<\/td>\n<td>a\u7684\u5b50\u5143\u7d20\u4e2d\uff0c\u7b2cindex\u4e2a\u4e0eb\u5339\u914d\u7684\u5143\u7d20\uff08\u4ece1\u5f00\u59cb\u8ba1\u6570\uff09<\/td>\n<\/tr>\n<tr>\n<td>a b:nth-child(even)<\/td>\n<td>a\u7684\u5b50\u5143\u7d20\u4e2d\uff0c\u7b2c\u5076\u6570\u4e2a\u4e0eb\u5339\u914d\u7684\u5143\u7d20\uff08\u4ece1\u5f00\u59cb\u8ba1\u6570\uff09<\/td>\n<\/tr>\n<tr>\n<td>a b:nth-child(odd)<\/td>\n<td>a\u7684\u5b50\u5143\u7d20\u4e2d\uff0c\u7b2c\u5947\u6570\u4e2a\u4e0eb\u5339\u914d\u7684\u5143\u7d20\uff08\u4ece1\u5f00\u59cb\u8ba1\u6570\uff09<\/td>\n<\/tr>\n<tr>\n<td>a b:nth-child(2n+2)<\/td>\n<td>a\u7684\u5b50\u5143\u7d20\u4e2d\uff0c\u7b2c2n+2\u4e2a\u4e0eb\u5339\u914d\u7684\u5143\u7d20\uff08\u4ece1\u5f00\u59cb\u8ba1\u6570\uff09,n\u4e3a\u81ea\u7136\u6570<\/td>\n<\/tr>\n<tr>\n<td>a b:nth-last-child()<\/td>\n<td>\u540c:nth-child()\uff0c\u4ece\u6700\u540e\u4e00\u4e2a\u5143\u7d20\u5f00\u59cb\u8ba1\u6570<\/td>\n<\/tr>\n<tr>\n<td>a b:first-child<\/td>\n<td>a\u7684\u5b50\u5143\u7d20\u4e2d\uff0c\u7b2c1\u4e2a\u4e0eb\u5339\u914d\u7684\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>a b:last-child<\/td>\n<td>a\u7684\u5b50\u5143\u7d20\u4e2d\uff0c\u6700\u540e\u4e00\u4e2a\u4e2a\u4e0eb\u5339\u914d\u7684\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>:only-child<\/td>\n<td>\u4f5c\u4e3a\u5176\u7236\u5143\u7d20\u552f\u4e00\u4e00\u4e2a\u5b50\u5143\u7d20\u7684\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>a b:nth-of-type()<\/td>\n<td>\u540c:nth-child()\uff0c\u53ea\u8ba1\u540c\u7c7b\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>a b:nth-last-of-type()<\/td>\n<td>\u540c:nth-last-child()\uff0c\u53ea\u8ba1\u540c\u7c7b\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>a b:first-of-type()<\/td>\n<td>\u540c:first-child()\uff0c\u53ea\u8ba1\u540c\u7c7b\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>a b:last-of-type()<\/td>\n<td>\u540c:last-child()\uff0c\u53ea\u8ba1\u540c\u7c7b\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>a b:only-of-type()<\/td>\n<td>\u6ca1\u6709\u540c\u540d\u5143\u7d20\u7684\u5143\u7d20<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div class=\"md-section-divider\"><\/div>\n<h3 id=\"3\u5c5e\u6027\u9009\u62e9\u5668\" data-anchor-id=\"xcmi\">3\u3001\u5c5e\u6027\u9009\u62e9\u5668<\/h3>\n<table class=\"table table-striped-white table-bordered\" data-anchor-id=\"pekl\">\n<thead>\n<tr>\n<th>\u9009\u62e9\u7b26<\/th>\n<th>\u5339\u914d\u5143\u7d20<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>[attr]<\/td>\n<td>\u5e26\u6709\u5c5e\u6027attr\u7684\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>[attr=&#8221;value&#8221;]<\/td>\n<td>attr\u5c5e\u6027\u503c\u4e3avalue\u7684\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>[attr!=&#8221;value&#8221;]<\/td>\n<td>attr\u5c5e\u6027\u503c\u4e0d\u4e3avalue\u7684\u5143\u7d20\uff09<\/td>\n<\/tr>\n<tr>\n<td>[attr^=&#8221;value&#8221;]<\/td>\n<td>attr\u5c5e\u6027\u503c\u4ee5value\u5f00\u5934\u7684\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>[attr$=&#8221;value&#8221;]<\/td>\n<td>attr\u5c5e\u6027\u503c\u4ee5value\u7ed3\u5c3e\u7684\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>[attr*=&#8221;value&#8221;]<\/td>\n<td>attr\u5c5e\u6027\u503c\u5305\u542bvalue\u5b57\u7b26\u4e32\u7684\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>[attr~=&#8221;value&#8221;]<\/td>\n<td>attr\u5c5e\u6027\u503c\u662f\u7a7a\u683c\u5206\u9694\u7684\u5b57\u7b26\u4e32\uff0c\u5176\u4e2d\u4e00\u4e2a\u5b57\u7b26\u4e32\u503c\u662fvalue\u7684\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>[attr|=&#8221;value&#8221;]<\/td>\n<td>attr\u5c5e\u6027\u503c\u7b49\u4e8evalue\u6216value\u540e\u8ddf\u4e00\u4e2a\u8fde\u5b57\u7b26(-)\u7684\u5143\u7d20<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div class=\"md-section-divider\"><\/div>\n<h3 id=\"4\u8868\u5355\u9009\u62e9\u5668\" data-anchor-id=\"du8l\">4\u3001\u8868\u5355\u9009\u62e9\u5668<\/h3>\n<table class=\"table table-striped-white table-bordered\" data-anchor-id=\"4xtd\">\n<thead>\n<tr>\n<th>\u9009\u62e9\u7b26<\/th>\n<th>\u5339\u914d\u5143\u7d20<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>:input<\/td>\n<td>\u6240\u6709<code>&lt;input&gt;<\/code>\u3001<code>&lt;textarea&gt;<\/code>\u3001<code>&lt;select&gt;<\/code>\u548c<code>&lt;button&gt;<\/code>\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>:text<\/td>\n<td>type=\u201dtext\u201d\u7684<code>&lt;input&gt;<\/code>\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>:password<\/td>\n<td>type=\u201dpassword\u201d\u7684<code>&lt;input&gt;<\/code>\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>:file<\/td>\n<td>type=\u201dfile\u201d\u7684<code>&lt;input&gt;<\/code>\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>:radio<\/td>\n<td>type=\u201dradio\u201d\u7684<code>&lt;input&gt;<\/code>\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>:checkbox<\/td>\n<td>type=\u201dcheckbox\u201d\u7684<code>&lt;input&gt;<\/code>\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>:submit<\/td>\n<td>type=\u201dsubmit\u201d\u7684<code>&lt;input&gt;<\/code>\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>:image<\/td>\n<td>type=\u201dimage\u201d\u7684<code>&lt;input&gt;<\/code>\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>:reset<\/td>\n<td>type=\u201dreset\u201d\u7684<code>&lt;input&gt;<\/code>\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>:button<\/td>\n<td>type=\u201dbutton\u201d\u7684<code>&lt;input&gt;<\/code>\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>:enabled<\/td>\n<td>\u542f\u7528\u7684\u8868\u5355\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>:disabled<\/td>\n<td>\u7981\u7528\u7684\u8868\u5355\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>:checked<\/td>\n<td>\u9009\u4e2d\u7684\u590d\u9009\u6846\u548c\u5355\u9009\u6309\u94ae<\/td>\n<\/tr>\n<tr>\n<td>:selected<\/td>\n<td>\u9009\u4e2d\u7684<code>&lt;option&gt;<\/code>\u5143\u7d20<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div class=\"md-section-divider\"><\/div>\n<h3 id=\"5\u8fc7\u6ee4\u9009\u62e9\u5668\" data-anchor-id=\"582m\">5\u3001\u8fc7\u6ee4\u9009\u62e9\u5668<\/h3>\n<table class=\"table table-striped-white table-bordered\" data-anchor-id=\"pohq\">\n<thead>\n<tr>\n<th>\u9009\u62e9\u7b26<\/th>\n<th>\u5339\u914d\u5143\u7d20<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>:root<\/td>\n<td>\u6587\u6863\u6839\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>:header<\/td>\n<td>\u6807\u9898\u5143\u7d20\uff0ch1~h6<\/td>\n<\/tr>\n<tr>\n<td>:animated<\/td>\n<td>\u52a8\u753b\u6b63\u5728\u8fd0\u884c\u7684\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>:contains(text)<\/td>\n<td>\u5305\u542b\u6587\u672ctext\u7684\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>a:empty<\/td>\n<td>\u4e0d\u5305\u542b\u5b50\u8282\u70b9\u7684a\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>a:has(b)<\/td>\n<td>\u81f3\u5c11\u5305\u542b\u4e00\u4e2ab\u5143\u7d20\u5339\u914d\u7684a\u5143\u7d20(\u8fd4\u56de\u7236\u5143\u7d20a\u800c\u975e\u5b50\u5143\u7d20b)<\/td>\n<\/tr>\n<tr>\n<td>:parent<\/td>\n<td>\u4e0e:empty\u76f8\u53cd\uff0c\u8fd4\u56de\u5305\u542b\u5b50\u8282\u70b9\u7684\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>:hidden<\/td>\n<td>\u9690\u85cf\u7684\u5143\u7d20\uff0c\u5305\u62ec<code>&lt;input type=\"hidden\"&gt;<\/code><\/td>\n<\/tr>\n<tr>\n<td>:visible<\/td>\n<td>\u53ef\u89c1\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>:focus<\/td>\n<td>\u83b7\u5f97\u7126\u70b9\u7684\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>:lang(language)<\/td>\n<td>\u7ed9\u5b9a\u8bed\u8a00\u4ee3\u7801\u7684\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>:target<\/td>\n<td>URI\u6807\u8bc6\u7b26\u6307\u5411\u7684\u76ee\u6807\u5143\u7d20\uff0c\u5177\u4f53\u89c1\uff1a<a title=\"\" href=\"http:\/\/www.ido321.com\/1567.html\" target=\"_blank\" data-original-title=\"\">:target\u7528\u6cd5<\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div class=\"md-section-divider\"><\/div>\n<h3 id=\"6\u7528\u4e8e\u7ed3\u679c\u96c6\u4e2d\u7684\u9009\u62e9\u5668\" data-anchor-id=\"15zt\">6\u3001\u7528\u4e8e\u7ed3\u679c\u96c6\u4e2d\u7684\u9009\u62e9\u5668<\/h3>\n<p data-anchor-id=\"fg25\">\u8fd9\u7c7b\u9009\u62e9\u5668\u5728CSS\u4e2d\u4e0d\u5b58\u5728\uff0c\u4f46\u53ef\u4ee5\u7528\u4e8eJQuery\u7684\u7ed3\u679c\u4e2d\u8fdb\u884c\u7b5b\u9009\u3002<\/p>\n<table class=\"table table-striped-white table-bordered\" data-anchor-id=\"ig8p\">\n<thead>\n<tr>\n<th>\u9009\u62e9\u7b26<\/th>\n<th>\u5339\u914d\u5143\u7d20<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>:first<\/td>\n<td>\u7ed3\u679c\u96c6\u4e2d\u7684\u7b2c\u4e00\u4e2a\u5143\u7d20\uff0c\u5bf9\u5e94\u65b9\u6cd5\u4e3afirst(),\u5982<code>$(\"a b:first\")<\/code>&lt;==&gt;<code>$(\"a b\").first()<\/code><\/td>\n<\/tr>\n<tr>\n<td>:last<\/td>\n<td>\u7ed3\u679c\u96c6\u4e2d\u7684\u6700\u540e\u4e00\u4e2a\u5143\u7d20\uff0c\u5bf9\u5e94\u65b9\u6cd5\u4e3alast(),\u5982<code>$(\"a b:last\")<\/code>&lt;==&gt;<code>$(\"a b\").last()<\/code><\/td>\n<\/tr>\n<tr>\n<td>:not(a)<\/td>\n<td>\u7ed3\u679c\u96c6\u4e2d\u4e0d\u4e0ea\u5339\u914d\u7684\u5143\u7d20\uff0c\u5bf9\u5e94\u65b9\u6cd5\u4e3anot(),\u5982<code>$(\"a b:not(c)\")<\/code>&lt;==&gt;<code>$(\"a b\").not(c)<\/code><\/td>\n<\/tr>\n<tr>\n<td>:even<\/td>\n<td>\u7ed3\u679c\u96c6\u4e2d\u7d22\u5f15\u662f\u5076\u6570\u7684\u5143\u7d20(\u4ece0\u5f00\u59cb),\u5982<code>$(\"a b:even\")<\/code><\/td>\n<\/tr>\n<tr>\n<td>:odd<\/td>\n<td>\u7ed3\u679c\u96c6\u4e2d\u7d22\u5f15\u662f\u5947\u6570\u7684\u5143\u7d20(\u4ece0\u5f00\u59cb),\u5982<code>$(\"a b:odd\")<\/code><\/td>\n<\/tr>\n<tr>\n<td>:eq(index)<\/td>\n<td>\u7ed3\u679c\u96c6\u4e2d\u7d22\u5f15\u662findex\u7684\u5143\u7d20(\u4ece0\u5f00\u59cb),\u5bf9\u5e94\u65b9\u6cd5\u662feq(index),\u5982<code>$(\"a b:eq(2)\")<\/code>&lt;==&gt;<code>$(\"a b\").eq(2)<\/code><\/td>\n<\/tr>\n<tr>\n<td>:gt(index)<\/td>\n<td>\u7ed3\u679c\u96c6\u4e2d\u7d22\u5f15\u5927\u4e8eindex\u7684\u5143\u7d20(\u4ece0\u5f00\u59cb),\u5982<code>$(\"a b:gt(2)\")<\/code><\/td>\n<\/tr>\n<tr>\n<td>:lt(index)<\/td>\n<td>\u7ed3\u679c\u96c6\u4e2d\u7d22\u5f15\u5c0f\u4e8eindex\u7684\u5143\u7d20(\u4ece0\u5f00\u59cb),\u5982<code>$(\"a b:lt(2)\")<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6765\u6e90\uff1a<a title=\"\" href=\"http:\/\/www.ido321.com\/\" data-original-title=\"\">\u6de1\u5fd8~\u6d45\u601d<\/a> \u00bb <a title=\"\" href=\"http:\/\/www.ido321.com\/1602.html\" data-original-title=\"\">JQuery\u603b\u7ed3\u4e00\uff1a\u9009\u62e9\u5668\u5f52\u7eb3<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u57fa\u672c\u9009\u62e9\u5668 \u9009\u62e9\u7b26 \u5339\u914d\u5143\u7d20 * \u6240\u6709\u5143\u7d20 id \u7ed9\u5b9aID\u7684\u5143\u7d20 element \u7ed9\u5b9a\u7c7b\u578b\u7684\u6240\u6709\u5143\u7d20 .c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[66],"tags":[67,923],"_links":{"self":[{"href":"https:\/\/www.ecjtu.com\/keith\/wp-json\/wp\/v2\/posts\/2999"}],"collection":[{"href":"https:\/\/www.ecjtu.com\/keith\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ecjtu.com\/keith\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ecjtu.com\/keith\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ecjtu.com\/keith\/wp-json\/wp\/v2\/comments?post=2999"}],"version-history":[{"count":1,"href":"https:\/\/www.ecjtu.com\/keith\/wp-json\/wp\/v2\/posts\/2999\/revisions"}],"predecessor-version":[{"id":3000,"href":"https:\/\/www.ecjtu.com\/keith\/wp-json\/wp\/v2\/posts\/2999\/revisions\/3000"}],"wp:attachment":[{"href":"https:\/\/www.ecjtu.com\/keith\/wp-json\/wp\/v2\/media?parent=2999"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ecjtu.com\/keith\/wp-json\/wp\/v2\/categories?post=2999"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ecjtu.com\/keith\/wp-json\/wp\/v2\/tags?post=2999"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}