Js+css Simple realization of Web page skin-changing effect _javascript skills

Source: Internet
Author: User

This article describes the JS+CSS simple to achieve a Web page skin-changing effect. Share to everyone for your reference, specific as follows:

Here do 3 sets of appearance, using different folders under the same name CSS file, then how to implement JS replacement load it?

The 3 buttons are as follows:

<a id= "skin1" href= "javascript:void (0)" class= "Easyui-linkbutton" onclick= "changecss (' Default ')" > Blue skin </a ><br/><br/>
<a id= "skin2" href= "Javascript:void" (0) "class=" Easyui-linkbutton "onclick=" Changecss (' Gray ') "> Grey skin </a><br/><br/>
<a id=" skin3 "href=" javascript:void (0) "class=" Easyui-linkbutton "onclick=" changecss (' unite ') > Custom Skin </a>

JS Code:

Replace the theme
function Changecss (cssname) {
  if (document.getelementsbytagname_r ("link"). Length > 0) {for
   ( var i = 0; I < Document.getelementsbytagname_r ("link"). Length; i++) {
    var ctrllink = document.getelementsbytagname_r ("link") [I];
    var cssold = Ctrllink.getattribute ("href");
    var cssnew = cssold.replace ("Default", Cssname);
    Cssnew = Cssnew.replace ("Gray", cssname);
    Cssnew = Cssnew.replace ("unite", Cssname);
    Ctrllink.setattribute ("href", cssnew);
   }
  }


Implementation effect:

I hope this article will help you with JavaScript programming.

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.