JavaScript code to achieve skin-changing effects

Source: Internet
Author: User
The default skin for these three nodes is three colors, and each node can be skinned independently and unaffected. Once the skin of a node has been replaced, the skin of the list page and content page under this node will also be replaced with it. This skin-changing approach is as follows:
Analysis of source code can find a few points
1, first to load four files at the top of the page:
The focus here is to give the CSS file ID, as well as the default skin path, the principle is to change the folder path to read different CSS and pictures to achieve the effect of skin change.
2 ,
Here is the structure code to toggle the button area of the skin
3, and finally insert the following code in the page:
The code is as follows Copy Code
<script language= "javascript" type= "Text/javascript" >
         (function (e,d,c) {var b=["#css_zwp"];var a=function (g) {var f= $ (b[0]). attr ("href"). Split ("/") [$ (b[0]). attr ("href"). Split ("/"). Length-2];$.each (B,function (h) {if ($ (b[h)). Size ()!=0) {$ (b[h]). attr ("href", $ (b[h)). attr ("href"). Replace (F,g.find ("a"). attr ("rel"))}};if ($.cookie (d) ==null) { $ (E). each (function (f) {var g=$ (b[0]). attr ("/"). Split ("/") [$ (b[0])-attr ("href"). Split ("/"). Length-2];if ($ (This ). Find ("a"). attr ("rel") ==g) {$ (a). Parent (). Children (). Removeclass (c)-eq (f). AddClass (c)})}else{a ($ (e). EQ ($. Cookie (d)); $ (e). Removeclass (c). EQ ($.cookie (d)). AddClass (c)}$ (e). Click (Function (g) {A ($ (this)), Var h=$ (this). Parent (). Children (); var f=$.inarray (this,h); $.cookie (D,f,{path: "/", Expires:new date (new Date ()) GetTime )}); H.removeclass (c). EQ (f). AddClass (c); G.stoppropagation ()}) (". Theme Li", "theme2", "cur");
(function (e,d,c) {var b=["#css_zw"];var a=function (g) {var f=$ (b[0]). attr ("href"). Split ("/") [$ (b[0]). attr ("href"). Split ("/"). Length-2];$.each (B,function (h) {if ($ (b[h)). Size ()!=0) {$ (b[h]). attr ("href", $ (b[h)). attr ("href"). Replace (F,g.find ("a"). attr ("rel"))};if ($.cookie (d) ==null) {$ (E). each (function (f) {var g=$ (b[0)). attr ("href"). Split ("/") [$ (b[0]). attr ("href"). Split ("/"). Length-2];if ($ (this). Find ("a"). attr ("rel") ==g) {$ (this). Parent (). Children (). Removeclass (c). EQ (f). AddClass (c)})}else{a ($ (e). EQ ($.cookie (d))), $ (e). Removeclass (c). EQ ($.cookie (d) ). AddClass (c)}$ (e). Click (Function (g) {A ($ (this)), Var h=$ (this). Parent (). Children (); var f=$.inarray (THIS,H); $. Cookie (D,f,{path: "/", Expires:new date (new Date (). GetTime () 24*3600*100)}), H.removeclass (c). EQ (f). AddClass (c); G.stoppropagation ()})} (". Theme Li", "theme2", "cur");
</script>
Notice here that the ID corresponds to the ID that loads the CSS.
In each page plus the above three points can be achieved linkage skin, and finally how to achieve the node before each other affect the skin, only to change the 3rd at the end (". Theme Li", "theme2", "cur") in the middle of theme2 this parameter.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.