Jquery+css implement the theme transform of Web page color (change only several color themes that have been set)

Source: Internet
Author: User

Also encountered color theme changes, this time using the JQUERY+CSS, using the function of the value, rather than the previous site changes the way link.

First of all, after setting the color theme, click Change page color theme. (You need to import jquery.js yourself to see the effect)

Direct Sticker Code:

<!DOCTYPE HTML><HTMLLang= "en"><Head>    <MetaCharSet= "UTF-8">    <title>Document</title>    <Scripttype= "Text/javascript"src= "Js/jquery.js"></Script></Head><style>Div Section{width:30px;Height:30px;margin:10px;Display:Inline-block;     }Div Section:nth-of-type (1){Background-color:#177cb0;     }Div Section:nth-of-type (2){Background-color:#db5a6b;     }Div Section:nth-of-type (3){Background-color:#008000;     }Div Section:hover{cursor:Pointer;    }</style><Body>    <Div>        < Sectiononclick= "Blue ()"></ Section>        < Sectiononclick= "Red ()"></ Section>        < Sectiononclick= "Green ()"></ Section>    </Div>        <Center>        <H2style= "Display:inline-block;">Color Theme jquery Transform</H2>        <formAction=""ID= "SimpleCalc">            <span>Input</span><inputtype= "text"Required><BR><BR>            <ButtonID= "Calc">Confirm</Button>        </form>        <spanID= "Result"></span>    </Center>    <Script>      //set the default color theme$ (document). Ready (function() {blue ();        }); //Click a single color change        functionBlue () {Change ("#177cb0"); }        functionRed () {Change ("#db5a6b"); }        functionGreen () {Change ("#008000"); }        //set the elements and their styles that need to change color        functionChange (colo) {$ ("#calc"). CSS ("Background-color", Colo); $("H2, span"). CSS ("Color", Colo); $("input"). CSS ("Color", Colo); $("Input[type=text]"). Focus (function(){$( This). CSS ("Outline", "None")}); $("Input[type=text]"). Focus (function(){$( This). CSS ("Border", "2px Solid" +Colo)}); $("Input[type=text]"). Blur (function(){$( This). CSS ("Border", "1px solid Gray")}); }    </Script></Body></HTML>    

Next post code that changes the color theme in real time (by inputting the color value by input).

If there is any mistake, please correct me!

Jquery+css implement Web page color theme Transformations (change only several color themes that have been set)

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.