Summary of the use of Theme and Theme Switcher in jquery

Source: Internet
Author: User

First, let's take a picture. The effect is good:

I. Introduce theme of jquery 
Reference the CSS links of jquery themes in the head, such as Ghost, black-tie, blitzer, cupertino, dark-hive, dot-luv, eggplant, excite-bike, flick, hot-sneaks, humanity, le-frog, mint-choc, overcast, pepper-grinder, redmond, smoothness, south-street, start, sunny, swanky-purse, trontastic, ui-darkness, ui-lightness, vader. You only need to replace the base in the above link with the topic name to switch between different topics.

Ii. Use theme of jquery 
Add a class to the part to be decorated, for example: <a class = "ui-state-default ui-corner-all" href = "#"> Nothing's gonna change my love for you </a> indicates the default ui, corner-all indicates four smooth corners.

 

3. Increase the hover Effect

The jquery script is used here. First, introduce the jquery library in the head.
<Script type = "text/javascript" src = "http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"> </script>
1.3 indicates the latest version in 1.3, Which is 1.3.2.
Then hand-written scripts;
Copy codeThe Code is as follows:
$ (Function () {$ ('. ui-state-default '). hover (function () {$ (this ). addClass ('ui-state-hover ');}, function () {$ (this ). removeClass ('ui-state-hover ');});});

In this way, the effect of changing the style is achieved by moving the mouse over the top.

4. Use Theme Switcher to change the topic at the front end
Import to Warehouse first
Copy codeThe Code is as follows:
<Script type = "text/javascript" src = "http://jqueryui.com/themeroller/themeswitchertool/"> </script>

And you can add the <div id = "switcher"> topic switching function to load any part of the page... </div>, I am used to making the wikget of the switch into an apDiv layer to facilitate moving the appropriate location. Finally, the handwriting script activates this layer:
$ ('# Switcher'). themeswitcher ();

5. Make webpages remember their themes 
Every time you change the subject, jquery will write a cookie. To make the webpage remember its own subject, you only need to extract the cookie and refresh the css of the page.
Write the script
Copy codeThe Code is as follows:
$ (Function () {if (theme = null) updateCSS ("http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/base/jquery-ui.css"); else updateCSS ("http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/" + theme + "/jquery-ui.css ");})
Function updateCSS (locStr) {var cssLink = $ ('<link href = "' + locStr + '" type = "text/css" rel = "Stylesheet" class = "ui-theme"/>' ); $ ("head "). append (cssLink); if ($ ("link. ui-theme "). size ()> 3) {$ ("link. ui-theme: first "). remove ();}}

The final page code is like this:
Copy codeThe Code is as follows:
Signature <? Xml version = "1.0" encoding = "UTF-8"?>
<% @ Page language = "java" contentType = "text/html; charset = UTF-8"
PageEncoding = "UTF-8" %>
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Style type = "text/css">
# Switcher {
Position: absolute;
Left: 564px;
Top: 20px;
}
</Style>
<Script src = "http://www.google.com/jsapi"> </script>
<Script type = "text/javascript"> google. load ("jquery", "1.3.2"); google. load ("jqueryui", "1.7.2"); function onload({}}('{switcher'}.html (""); var theme = $. cookie ('jquery-ui-theme '); $ (function () {if (theme = null) updateCSS ("http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/base/jquery-ui.css "); else updateCSS ("http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/" + theme + "/jquery-ui.css");}); $ (function () {$ ('. ui-state-default '). hover (function () {$ (this ). addClass ('ui-state-hover ');}, function () {$ (this ). removeClass ('ui-state-hover ') ;}); $ ("# pic2 "). hide (); $ ('# switcher '). themeswitcher ();} google. setOnLoadCallback (OnLoad); function updateCSS (locStr) {var cssLink = $ ('<link href = "' + locStr + '" type = "text/css" rel = "Stylesheet" class = "ui-theme"/>' ); $ ("head "). append (cssLink); if ($ ("link. ui-theme "). size ()> 3) {$ ("link. ui-theme: first "). remove ();}}
</Script>
<Script type = "text/javascript" src = "http://jqueryui.com/themeroller/themeswitchertool/"> </script>
</Script>
<Title> </title>
</Head>
<Body>
<Div id = "switcher"> the topic switching function is loading... </div>
<P> <a class = "ui-state-default ui-corner-all" href = "http://mee-moo.googlecode.com/svn/trunk/resource/music/nothinggcmlfu.mp3"> Nothing's gonna change my love for you </a> </ p>
</Body>
</Html>

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.