{"id":849,"date":"2011-11-18T12:34:24","date_gmt":"2011-11-18T04:34:24","guid":{"rendered":"http:\/\/feizhaojun.com\/?p=849"},"modified":"2017-04-14T18:09:40","modified_gmt":"2017-04-14T10:09:40","slug":"5%e4%b8%aa%e5%b8%b8%e7%94%a8jquery%e4%bb%a3%e7%a0%81%e7%89%87%e6%ae%b5","status":"publish","type":"post","link":"https:\/\/feizhaojun.com\/?p=849","title":{"rendered":"5\u4e2a\u5e38\u7528jQuery\u4ee3\u7801\u7247\u6bb5"},"content":{"rendered":"<p>\u539f\u6587\u94fe\u63a5\uff1a<a href=\"http:\/\/feizhaojun.com\/doc-archive\/5%E4%B8%AA%E5%B8%B8%E7%94%A8jQuery%E4%BB%A3%E7%A0%81%E7%89%87%E6%AE%B5.html\" target=\"_blank\">http:\/\/feizhaojun.com\/doc-archive\/5\u4e2a\u5e38\u7528jQuery\u4ee3\u7801\u7247\u6bb5.html<\/a><\/p>\n<div id=\"main\">\n<p>jQuery\u662f\u4e00\u6b3e\u4f18\u79c0\u7684js\u6846\u67b6\uff0c\u4e0b\u9762\u5217\u4e3e5\u4e2a\u5e38\u7528\u7684\u4ee3\u7801\u7247\u6bb5\u3002<\/p>\n<ol>\n<li>\n\u7981\u6b62\u53f3\u952e<\/p>\n<pre>$<span style=\"color: #009900;\">(<\/span>document<span style=\"color: #009900;\">)<\/span>.<span style=\"color: #660066;\">ready<\/span><span style=\"color: #009900;\">(<\/span><span style=\"color: #003366; font-weight: bold;\">function<\/span><span style=\"color: #009900;\">(<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #009900;\">{<\/span>\r\n$<span style=\"color: #009900;\">(<\/span>document<span style=\"color: #009900;\">)<\/span>.<span style=\"color: #660066;\">bind<\/span><span style=\"color: #009900;\">(<\/span><span style=\"color: #3366CC;\">\"contextmenu\"<\/span><span style=\"color: #339933;\">,<\/span><span style=\"color: #003366; font-weight: bold;\">function<\/span><span style=\"color: #009900;\">(<\/span>e<span style=\"color: #009900;\">)<\/span><span style=\"color: #009900;\">{<\/span>\r\n<span style=\"color: #000066; font-weight: bold;\">return<\/span> <span style=\"color: #003366; font-weight: bold;\">false<\/span><span style=\"color: #339933;\">;<\/span>\r\n<span style=\"color: #009900;\">}<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span>\r\n<span style=\"color: #009900;\">}<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span>\r\n<\/pre>\n<\/li>\n<li>\n\u7528jQuery\u5b9e\u73b0Flash\u6548\u679c<\/p>\n<pre class=\"javascript\" style=\"font-family:monospace;\">jQuery.<span style=\"color: #660066;\">fn<\/span>.<span style=\"color: #660066;\">flash<\/span> <span style=\"color: #339933;\">=<\/span> <span style=\"color: #003366; font-weight: bold;\">function<\/span><span style=\"color: #009900;\">(<\/span> color<span style=\"color: #339933;\">,<\/span> duration <span style=\"color: #009900;\">)<\/span>\r\n<span style=\"color: #009900;\">{<\/span>\r\n<span style=\"color: #003366; font-weight: bold;\">var<\/span> current <span style=\"color: #339933;\">=<\/span> <span style=\"color: #000066; font-weight: bold;\">this<\/span>.<span style=\"color: #660066;\">css<\/span><span style=\"color: #009900;\">(<\/span> <span style=\"color: #3366CC;\">'color'<\/span> <span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span>\r\n<span style=\"color: #000066; font-weight: bold;\">this<\/span>.<span style=\"color: #660066;\">animate<\/span><span style=\"color: #009900;\">(<\/span> <span style=\"color: #009900;\">{<\/span> color<span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366CC;\">'rgb('<\/span> <span style=\"color: #339933;\">+<\/span> color <span style=\"color: #339933;\">+<\/span> <span style=\"color: #3366CC;\">')'<\/span> <span style=\"color: #009900;\">}<\/span><span style=\"color: #339933;\">,<\/span> duration <span style=\"color: #339933;\">\/<\/span> <span style=\"color: #CC0000;\">2<\/span> <span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span>\r\n<span style=\"color: #000066; font-weight: bold;\">this<\/span>.<span style=\"color: #660066;\">animate<\/span><span style=\"color: #009900;\">(<\/span> <span style=\"color: #009900;\">{<\/span> color<span style=\"color: #339933;\">:<\/span> current <span style=\"color: #009900;\">}<\/span><span style=\"color: #339933;\">,<\/span> duration <span style=\"color: #339933;\">\/<\/span> <span style=\"color: #CC0000;\">2<\/span> <span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span>\r\n<span style=\"color: #009900;\">}<\/span>\r\n$<span style=\"color: #009900;\">(<\/span> <span style=\"color: #3366CC;\">'#someid'<\/span> <span style=\"color: #009900;\">)<\/span>.<span style=\"color: #660066;\">flash<\/span><span style=\"color: #009900;\">(<\/span> <span style=\"color: #3366CC;\">'255,0,0'<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #CC0000;\">1000<\/span> <span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span><span style=\"color: #006600; font-style: italic;\">\/\/#someid\u662f\u5143\u7d20\u7684id\u53f7<\/span>\r\n<\/pre>\n<\/li>\n<li>\n\u7f51\u9875\u8f7d\u5165\u5b8c\u6210\u65f6\u8fd0\u884c<\/p>\n<pre class=\"javascript\" style=\"font-family:monospace;\">$<span style=\"color: #009900;\">(<\/span><span style=\"color: #003366; font-weight: bold;\">function<\/span><span style=\"color: #009900;\">(<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #009900;\">{<\/span>\r\n<span style=\"color: #006600; font-style: italic;\">\/\/\u7f51\u9875\u8f7d\u5165\u5b8c\u6210\u65f6\u7684\u7a0b\u5e8f<\/span>\r\n<span style=\"color: #009900;\">}<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span><\/pre>\n<\/li>\n<li>\njQuery\u5224\u65ad\u6d4f\u89c8\u5668<\/p>\n<pre class=\"javascript\" style=\"font-family:monospace;\"><span style=\"color: #006600; font-style: italic;\">\/\/\u5982\u679c\u662f\u706b\u72d0<\/span>\r\n<span style=\"color: #000066; font-weight: bold;\">if<\/span><span style=\"color: #009900;\">(<\/span> $.<span style=\"color: #660066;\">browser<\/span>.<span style=\"color: #660066;\">mozilla<\/span> <span style=\"color: #009900;\">)<\/span>\r\n<span style=\"color: #009900;\">{<\/span>\r\n<span style=\"color: #006600; font-style: italic;\">\/\/do something<\/span>\r\n<span style=\"color: #009900;\">}<\/span>\r\n<span style=\"color: #006600; font-style: italic;\">\/\/\u5982\u679c\u662fsafari<\/span>\r\n<span style=\"color: #000066; font-weight: bold;\">if<\/span><span style=\"color: #009900;\">(<\/span> $.<span style=\"color: #660066;\">browser<\/span>.<span style=\"color: #660066;\">safari<\/span> <span style=\"color: #009900;\">)<\/span>\r\n<span style=\"color: #009900;\">{<\/span>\r\n<span style=\"color: #006600; font-style: italic;\">\/\/do something<\/span>\r\n<span style=\"color: #009900;\">}<\/span>\r\n<span style=\"color: #006600; font-style: italic;\">\/\/\u5982\u679c\u662f\u8c37\u6b4cchrome<\/span>\r\n <span style=\"color: #000066; font-weight: bold;\">if<\/span><span style=\"color: #009900;\">(<\/span> $.<span style=\"color: #660066;\">browser<\/span>.<span style=\"color: #660066;\">chrome<\/span> <span style=\"color: #009900;\">)<\/span>\r\n<span style=\"color: #009900;\">{<\/span>\r\n<span style=\"color: #006600; font-style: italic;\">\/\/do something<\/span>\r\n<span style=\"color: #009900;\">}<\/span>\r\n<span style=\"color: #006600; font-style: italic;\">\/\/\u5982\u679c\u662fopera\u6d4f\u89c8\u5668<\/span>\r\n<span style=\"color: #000066; font-weight: bold;\">if<\/span><span style=\"color: #009900;\">(<\/span> $.<span style=\"color: #660066;\">browser<\/span>.<span style=\"color: #660066;\">opera<\/span> <span style=\"color: #009900;\">)<\/span>\r\n<span style=\"color: #009900;\">{<\/span>\r\n<span style=\"color: #006600; font-style: italic;\">\/\/do something<\/span>\r\n<span style=\"color: #009900;\">}<\/span>\r\n<span style=\"color: #006600; font-style: italic;\">\/\/\u5982\u679c\u662fIE6\u4ee5\u4e0a\u7248\u672c\uff0c\u5373IE7\u3001IE8...<\/span>\r\n<span style=\"color: #000066; font-weight: bold;\">if<\/span> <span style=\"color: #009900;\">(<\/span>$.<span style=\"color: #660066;\">browser<\/span>.<span style=\"color: #660066;\">msie<\/span> <span style=\"color: #339933;\">&amp;&amp;<\/span> $.<span style=\"color: #660066;\">browser<\/span>.<span style=\"color: #660066;\">version<\/span> <span style=\"color: #339933;\">&gt;<\/span> <span style=\"color: #CC0000;\">6<\/span> <span style=\"color: #009900;\">)<\/span>\r\n<span style=\"color: #009900;\">{<\/span>\r\n<span style=\"color: #006600; font-style: italic;\">\/\/do something<\/span>\r\n<span style=\"color: #009900;\">}<\/span>\r\n<span style=\"color: #006600; font-style: italic;\">\/\/ \u5982\u679c\u662fIE6\u6216\u8005\u66f4\u4f4e\u7248\u672c<\/span>\r\n<span style=\"color: #000066; font-weight: bold;\">if<\/span> <span style=\"color: #009900;\">(<\/span>$.<span style=\"color: #660066;\">browser<\/span>.<span style=\"color: #660066;\">msie<\/span> <span style=\"color: #339933;\">&amp;&amp;<\/span> $.<span style=\"color: #660066;\">browser<\/span>.<span style=\"color: #660066;\">version<\/span> <span style=\"color: #339933;\">&lt;=<\/span> <span style=\"color: #CC0000;\">6<\/span> <span style=\"color: #009900;\">)<\/span>  \r\n<span style=\"color: #009900;\">{<\/span> \r\n<span style=\"color: #006600; font-style: italic;\">\/\/do something <\/span>\r\n<span style=\"color: #009900;\">}<\/span>\r\n<\/pre>\n<\/li>\n<li>\n\u5224\u65ad\u5143\u7d20\u662f\u5426\u5b58\u5728<\/p>\n<pre class=\"javascript\" style=\"font-family:monospace;\"><span style=\"color: #000066; font-weight: bold;\">if<\/span> <span style=\"color: #009900;\">(<\/span>$<span style=\"color: #009900;\">(<\/span><span style=\"color: #3366CC;\">\"#someDiv\"<\/span><span style=\"color: #009900;\">)<\/span>.<span style=\"color: #660066;\">length<\/span><span style=\"color: #009900;\">)<\/span> <span style=\"color: #009900;\">{<\/span>\r\n<span style=\"color: #006600; font-style: italic;\">\/\/\u5982\u679c\u5b58\u5728id\u4e3asomeDiv\u7684\u5143\u7d20\uff0c\u5219...<\/span>\r\n<span style=\"color: #009900;\">}<\/span>\r\n<\/pre>\n<\/li>\n<\/ol>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u539f\u6587\u94fe\u63a5\uff1ahttp:\/\/feizhaojun.com\/doc-archive\/5\u4e2a\u5e38\u7528jQuery\u4ee3\u7801\u7247\u6bb5.html j&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3,24,5],"tags":[],"class_list":["post-849","post","type-post","status-publish","format-standard","hentry","category-fe","category-jquery","category-javascript"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/feizhaojun.com\/index.php?rest_route=\/wp\/v2\/posts\/849","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/feizhaojun.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/feizhaojun.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/feizhaojun.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/feizhaojun.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=849"}],"version-history":[{"count":2,"href":"https:\/\/feizhaojun.com\/index.php?rest_route=\/wp\/v2\/posts\/849\/revisions"}],"predecessor-version":[{"id":851,"href":"https:\/\/feizhaojun.com\/index.php?rest_route=\/wp\/v2\/posts\/849\/revisions\/851"}],"wp:attachment":[{"href":"https:\/\/feizhaojun.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=849"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/feizhaojun.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=849"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/feizhaojun.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=849"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}