{"id":2565,"date":"2013-12-11T16:32:02","date_gmt":"2013-12-11T08:32:02","guid":{"rendered":"https:\/\/sdeno.com\/?p=2565"},"modified":"2013-12-11T16:32:02","modified_gmt":"2013-12-11T08:32:02","slug":"jquery-%e7%ae%80%e6%98%93%e7%9a%84%e5%9b%be%e7%89%87%e5%88%87%e6%8d%a2","status":"publish","type":"post","link":"https:\/\/sdeno.com\/?p=2565","title":{"rendered":"jquery \u7b80\u6613\u7684\u56fe\u7247\u5207\u6362"},"content":{"rendered":"<p><a href=\"https:\/\/sdeno.com\/wp-content\/uploads\/2013\/12\/mygundong.jpg\"><figure class=\"mdx-lazyload-container\" style=\"max-width:507px\"><div style=\"padding-top:30.374753451677%\"><\/div><div class=\"mdx-img-loading-sp mdui-valign\"><div><div class=\"mdui-spinner\"><\/div><\/div><\/div><img width=\"507\" height=\"154\" class=\"alignnone size-full wp-image-2566 lazyload\" title=\"jquery \u7b80\u6613\u7684\u56fe\u7247\u5207\u6362\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" data-src=\"https:\/\/sdeno.com\/wp-content\/uploads\/2013\/12\/mygundong.jpg\" alt=\"https:\/\/sdeno.com\/wp-content\/uploads\/2013\/12\/mygundong.jpg\" data-srcset=\"https:\/\/sdeno.com\/wp-content\/uploads\/2013\/12\/mygundong.jpg 507w, https:\/\/sdeno.com\/wp-content\/uploads\/2013\/12\/mygundong-300x91.jpg 300w, https:\/\/sdeno.com\/wp-content\/uploads\/2013\/12\/mygundong-500x151.jpg 500w\" sizes=\"auto, (max-width: 507px) 100vw, 507px\"><\/figure><\/a><br \/>\nCSS\u4ee3\u7801\uff1a<\/p>\n<p>[code]&lt;style type=&#8221;text\/css&#8221;&gt;<br \/>\n*{ margin:0; padding:0;}<br \/>\n.wrap_tv_tit{ height:50px;margin-bottom:10px;}<br \/>\n.wrap_tv_tit_l{ float:left;}<br \/>\n.wrap_tv_tit_r{ float:right;}<br \/>\n.wrap_tv_tit_r span{background:yellow; margin-right:10px; cursor:pointer}<\/p>\n<p>.wrap_tv{ border:1px solid red; height:140px; width:500px; overflow:hidden;}<br \/>\nli{ list-style-type:none; float:left; margin-right:25px;}<br \/>\nul{ position:absolute; height:50px; width:2000px;}<br \/>\n.wrap_tv_bg{ position:relative;width:100%;}<br \/>\n.name{ display:block;}<br \/>\n.mun_page{ background:red;}<br \/>\n&lt;\/style&gt;[\/code]<br \/>\njquery\u90e8\u5206\uff1a<\/p>\n<p>[code]&lt;script type=&#8221;text\/javascript&#8221;&gt;<br \/>\n$(function(){<\/p>\n<p>var page = 1; \/\/\u5f53\u524d\u7248\u9762\u9875\u7801<br \/>\n$(&#8216;div.wrap_tv_tit_l&#8217;).children(&#8216;span&#8217;).eq(0).addClass(&#8216;mun_page&#8217;); \/\/\u9ed8\u8ba4\u5f53\u524d\u9875\u7801\u9ad8\u4eae<br \/>\n$(&#8216;.wrap_tv_tit_r span.r&#8217;).click(function(){ \/\/\u70b9\u51fb\u53f3\u952e\u65f6\u5019<br \/>\nif(!$(this).parents(&#8216;.wrap_tv&#8217;).find(&#8216;ul&#8217;).is(&#8216;:animated&#8217;)){ \/\/\u5f53\u70b9\u51fb\u53f3\u79fb\u52a8\u65f6\u5019\uff0c\u5982\u679c\u52a8\u753b\u5f53\u524d\u4e0d\u52a8\u5c31\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\uff1b\u5982\u679c\u52a8\u753b\u662f\u6b63\u5728\u5904\u4e8e\u52a8\u7684\u72b6\u6001\u8fd8\u70b9\u4e86\u5411\u53f3\u5c31\u4e0d\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e0d\u7ee7\u7eed\u8ffd\u52a0\uff1b\u6548\u679c\u5c31\u662f\u5f53\u70b9\u4e00\u6b21\u5411\u53f3\u65f6\u5019\uff0c\u5fc5\u987b\u7b49\u5f53\u524d\u7684\u52a8\u753b\u79fb\u52a8\u5b8c\u6bd5\u518d\u53bb\u70b9\u7684\u65f6\u5019\u624d\u6709\u6548\u679c\u3002<br \/>\nif(Math.ceil(($(this).parents(&#8216;.wrap_tv&#8217;).find(&#8216;ul li&#8217;).size())\/4)==page){ &lt;!&#8211;\u5224\u65ad\u7248\u9762\u603b\u6570\uff08\u5176\u5b9e\u662f4\uff09\u662f\u5426\u7b49\u4e8e \u5f53\u524d\u9875\u7801\u6570\uff08\u5176\u5b9e\u4e5f\u662f4\uff09&#8211;&gt;<br \/>\n$(this).parents(&#8216;.wrap_tv&#8217;).find(&#8216;ul&#8217;).animate({&#8216;left&#8217;:&#8217;0px&#8217;}); &lt;!&#8211;\u5982\u679c\u5230\u4e86\u6700\u540e\u4e00\u9875\uff0c\u5c31\u8fd4\u56de\u5230\u5f00\u59cb&#8211;&gt;<br \/>\npage=1; &lt;!&#8211;\u5982\u679c\u5230\u4e86\u6700\u540e\u4e00\u9875\uff0c\u8bf4\u660epage\u5df2\u7ecf\u662f4\u4e86\uff0c\u5c31\u8981\u4ece\u65b0\u8d4b\u503cpage=1,\u8fd9\u6837\u624d\u80fd\u4fdd\u8bc1\u7ee7\u7eed\u5faa\u73af\u70b9\u51fb&#8211;&gt;<br \/>\n}else{<br \/>\n$(this).parents(&#8216;.wrap_tv&#8217;).find(&#8216;ul&#8217;).animate({&#8216;left&#8217;:&#8217;-=&#8217;+$(this).parents(&#8216;.wrap_tv&#8217;).width()+&#8217;px&#8217;});<br \/>\npage=page+1;<br \/>\n}<br \/>\n$(&#8216;div.wrap_tv_tit_l&#8217;).children(&#8216;span&#8217;).removeClass(&#8216;mun_page&#8217;);<br \/>\n$(this).parents(&#8216;.wrap_tv&#8217;).find(&#8216;div.wrap_tv_tit_l&#8217;).children(&#8216;span&#8217;).eq(page-1).addClass(&#8216;mun_page&#8217;);<br \/>\n}<br \/>\n});<\/p>\n<p>$(&#8216;.wrap_tv_tit_r span.l&#8217;).click(function(){<br \/>\nif(page==1){<br \/>\n$(this).parents(&#8216;.wrap_tv&#8217;).find(&#8216;ul&#8217;).animate({&#8216;left&#8217;:&#8217;-=&#8217;+500*3+&#8217;px&#8217;});<br \/>\npage=Math.ceil(($(this).parents(&#8216;.wrap_tv&#8217;).find(&#8216;ul li&#8217;).size())\/4);<br \/>\n}else{<br \/>\n$(this).parents(&#8216;.wrap_tv&#8217;).find(&#8216;ul&#8217;).animate({&#8216;left&#8217;:&#8217;+=&#8217;+$(this).parents(&#8216;.wrap_tv&#8217;).width()+&#8217;px&#8217;});<br \/>\npage&#8211;;<br \/>\n}<br \/>\n$(&#8216;div.wrap_tv_tit_l&#8217;).children(&#8216;span&#8217;).removeClass(&#8216;mun_page&#8217;);<br \/>\n$(this).parents(&#8216;.wrap_tv&#8217;).find(&#8216;div.wrap_tv_tit_l&#8217;).children(&#8216;span&#8217;).eq(page-1).addClass(&#8216;mun_page&#8217;);<br \/>\n});<br \/>\n});<\/p>\n<p>&lt;\/script&gt;[\/code]<\/p>\n<p>html\u90e8\u5206\uff1a<\/p>\n<p>[code]&lt;div class=&#8221;wrap_tv&#8221;&gt;<br \/>\n&lt;div class=&#8221;wrap_tv_tit&#8221;&gt;<br \/>\n&lt;div class=&#8221;wrap_tv_tit_l&#8221;&gt;&lt;span&gt;1&lt;\/span&gt; &lt;span&gt;2&lt;\/span&gt; &lt;span&gt;3&lt;\/span&gt; &lt;span&gt;4&lt;\/span&gt;&lt;\/div&gt;<br \/>\n&lt;div class=&#8221;wrap_tv_tit_r&#8221;&gt;&lt;span class=&#8221;l&#8221;&gt;&amp;lt;&lt;span class=&#8221;r&#8221;&gt;&amp;gt;&lt;\/span&gt; &lt;\/span&gt;&lt;\/div&gt;<br \/>\n&lt;\/div&gt;<br \/>\n&lt;div class=&#8221;wrap_tv_bg&#8221;&gt;<br \/>\n&lt;ul&gt;<br \/>\n&lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;&lt;img alt=&#8221;&#8221; src=&#8221;images\/logo.png&#8221; width=&#8221;100&#8243; height=&#8221;50&#8243; \/&gt;&lt;\/a&gt;&lt;a class=&#8221;name&#8221;&gt;111&lt;\/a&gt;&lt;\/li&gt;<br \/>\n&lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;&lt;img alt=&#8221;&#8221; src=&#8221;images\/logo.png&#8221; width=&#8221;100&#8243; height=&#8221;50&#8243; \/&gt;&lt;\/a&gt;&lt;a class=&#8221;name&#8221;&gt;222&lt;\/a&gt;&lt;\/li&gt;<br \/>\n&lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;&lt;img alt=&#8221;&#8221; src=&#8221;images\/logo.png&#8221; width=&#8221;100&#8243; height=&#8221;50&#8243; \/&gt;&lt;\/a&gt;&lt;a class=&#8221;name&#8221;&gt;333&lt;\/a&gt;&lt;\/li&gt;<br \/>\n&lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;&lt;img alt=&#8221;&#8221; src=&#8221;images\/logo.png&#8221; width=&#8221;100&#8243; height=&#8221;50&#8243; \/&gt;&lt;\/a&gt;&lt;a class=&#8221;name&#8221;&gt;444&lt;\/a&gt;&lt;\/li&gt;<br \/>\n&lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;&lt;img alt=&#8221;&#8221; src=&#8221;images\/logo.png&#8221; width=&#8221;100&#8243; height=&#8221;50&#8243; \/&gt;&lt;\/a&gt;&lt;a class=&#8221;name&#8221;&gt;555&lt;\/a&gt;&lt;\/li&gt;<br \/>\n&lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;&lt;img alt=&#8221;&#8221; src=&#8221;images\/logo.png&#8221; width=&#8221;100&#8243; height=&#8221;50&#8243; \/&gt;&lt;\/a&gt;&lt;a class=&#8221;name&#8221;&gt;666&lt;\/a&gt;&lt;\/li&gt;<br \/>\n&lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;&lt;img alt=&#8221;&#8221; src=&#8221;images\/logo.png&#8221; width=&#8221;100&#8243; height=&#8221;50&#8243; \/&gt;&lt;\/a&gt;&lt;a class=&#8221;name&#8221;&gt;777&lt;\/a&gt;&lt;\/li&gt;<br \/>\n&lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;&lt;img alt=&#8221;&#8221; src=&#8221;images\/logo.png&#8221; width=&#8221;100&#8243; height=&#8221;50&#8243; \/&gt;&lt;\/a&gt;&lt;a class=&#8221;name&#8221;&gt;888&lt;\/a&gt;&lt;\/li&gt;<br \/>\n&lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;&lt;img alt=&#8221;&#8221; src=&#8221;images\/logo.png&#8221; width=&#8221;100&#8243; height=&#8221;50&#8243; \/&gt;&lt;\/a&gt;&lt;a class=&#8221;name&#8221;&gt;999&lt;\/a&gt;&lt;\/li&gt;<br \/>\n&lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;&lt;img alt=&#8221;&#8221; src=&#8221;images\/logo.png&#8221; width=&#8221;100&#8243; height=&#8221;50&#8243; \/&gt;&lt;\/a&gt;&lt;a class=&#8221;name&#8221;&gt;qqq1&lt;\/a&gt;&lt;\/li&gt;<br \/>\n&lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;&lt;img alt=&#8221;&#8221; src=&#8221;images\/logo.png&#8221; width=&#8221;100&#8243; height=&#8221;50&#8243; \/&gt;&lt;\/a&gt;&lt;a class=&#8221;name&#8221;&gt;www&lt;\/a&gt;&lt;\/li&gt;<br \/>\n&lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;&lt;img alt=&#8221;&#8221; src=&#8221;images\/logo.png&#8221; width=&#8221;100&#8243; height=&#8221;50&#8243; \/&gt;&lt;\/a&gt;&lt;a class=&#8221;name&#8221;&gt;eee&lt;\/a&gt;&lt;\/li&gt;<br \/>\n&lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;&lt;img alt=&#8221;&#8221; src=&#8221;images\/logo.png&#8221; width=&#8221;100&#8243; height=&#8221;50&#8243; \/&gt;&lt;\/a&gt;&lt;a class=&#8221;name&#8221;&gt;rrr&lt;\/a&gt;&lt;\/li&gt;<br \/>\n&lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;&lt;img alt=&#8221;&#8221; src=&#8221;images\/logo.png&#8221; width=&#8221;100&#8243; height=&#8221;50&#8243; \/&gt;&lt;\/a&gt;&lt;a class=&#8221;name&#8221;&gt;ttt&lt;\/a&gt;&lt;\/li&gt;<br \/>\n&lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;&lt;img alt=&#8221;&#8221; src=&#8221;images\/logo.png&#8221; width=&#8221;100&#8243; height=&#8221;50&#8243; \/&gt;&lt;\/a&gt;&lt;a class=&#8221;name&#8221;&gt;yyy&lt;\/a&gt;&lt;\/li&gt;<br \/>\n&lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;&lt;img alt=&#8221;&#8221; src=&#8221;images\/logo.png&#8221; width=&#8221;100&#8243; height=&#8221;50&#8243; \/&gt;&lt;\/a&gt;&lt;a class=&#8221;name&#8221;&gt;uuu&lt;\/a&gt;&lt;\/li&gt;<br \/>\n&lt;\/ul&gt;<br \/>\n&lt;\/div&gt;<br \/>\n&lt;\/div&gt;[\/code]<\/p>\n<p><a href=\"http:\/\/pan.baidu.com\/s\/128PX8\">\u6587\u4ef6\u4e0b\u8f7d<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>CSS\u4ee3\u7801\uff1a [code]&lt;style type=&#8221;text\/css&#8221;&gt;  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24,11],"tags":[],"class_list":["post-2565","post","type-post","status-publish","format-standard","hentry","category-jquery","category-11"],"_links":{"self":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/2565","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2565"}],"version-history":[{"count":0,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/2565\/revisions"}],"wp:attachment":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2565"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2565"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2565"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}