Web page becomes skin tone

Source: Internet
Author: User

<! DOCTYPE html>
<title> Web page Skin Change </title>
<script type= "Text/javascript" src= "Js/jquery-3.2.0.min.js" ></script>
<script type= "Text/javascript" src= "Js/jquery.cookie.js" ></script>
<link rel= "stylesheet" type= "Text/css" href= "Css/skin_0.css" id= "Cssfile" >
<style type= "Text/css" >
UL, ul li{
List-style:none;
margin:0;
padding:0;
}
. container{
width:400px;
padding:10px;
margin:0 Auto;
border:1px solid #999;
Overflow:hidden;

}
. skin{
Overflow:hidden;
}
. Skin li{
Float:left;
margin-right:5px;
width:15px;
height:15px;
/*text-indent:-999px;*/
/*overflow:hidden;*/
Display:block;
Cursor:pointer;
Background-image:url (img/theme.gif);
position:relative;

}
. Skin li input[type= "checkbox"]{
Position:absolute;
left:0;
top:0;
margin:0;
width:15px;
height:15px;
}
. slide_1,.slide_2{
Float:left;
width:160px;
margin:10px 10px;
Text-align:center;
}
#skin_0 {
background-position:0px 0px;
}
#skin_1 {
background-position:15px 0px;
}
#skin_2 {
background-position:35px 0px;
}
#skin_3 {
background-position:55px 0px;
}
#skin_4 {
background-position:75px 0px;
}
#skin_5 {
background-position:95px 0px;
}
#skin_0. selected{
background-position:0px 15px!important;
}
#skin_1. selected{
background-position:15px 15px!important;
}
#skin_2. selected{
background-position:35px 15px!important;
}
#skin_3. selected{
background-position:55px 15px!important;
}
#skin_4. selected{
background-position:75px 15px!important;
}
#skin_5. selected{
background-position:95px 15px!important;
}

</style>
<body>
<div class= "Container" >
<ul class= "Skin" >
<li id= "skin_0" title= "Gray" ><input type= "checkbox" Name= "" hidden></li>
<li id= "skin_1" title= "Pink" ><input type= "checkbox" Name= "" hidden></li>
<li id= "skin_2" title= "Blue" ><input type= "checkbox" Name= "" hidden></li>
<li id= "skin_3" title= "yellow" ><input type= "checkbox" Name= "" hidden></li>
<li id= "Skin_4" title= "green" ><input type= "checkbox" Name= "" hidden></li>
<li id= "skin_5" title= "green" ><input type= "checkbox" Name= "" hidden></li>
</ul>
<div class= "Slide_1" >
<div class= "News" ></div>
<div class= "Slide_2" >
<div class= "Game" ></div>
</div>
<script type= "Text/javascript" >
var $li =$ (". Skin Li");
$li. Click (function () {
$ ("#" +this.id). AddClass (' selected ')//current <li> element selected
. siblings (). Removeclass (' selected ');//Remove the selection of other peers <li> elements
$ ("#cssfile"). attr (' href ', ' css/' +this.id+ '. css ');//Set different skin tones
$.cookie ("MySkin", This.id, {path: '/', expires:10});//New Cookie
var Cookie_skin=$.cookie ("MySkin");//Get the value of a cookie
if (Cookie_skin) {
$ ("#" +cookie_skin). AddClass (' selected ')
. siblings (). Removeclass (' selected ');
$ ("#cssfile"). attr (' href ', ' css/' +cookie_skin+ '. css ');
$.cookie ("MySkin", Cookie_skin, {path: '/', expires:10});
}
}). Change (function (event) {
$ (this). Find (': CheckBox '). attr (' checked ', true)
. End ()
. siblings (). Find (': CheckBox '). attr (' checked ', false);
return false;
});

Method 2
$li. Click (function () {
Cssskin (this.id);
var Cookie_skin=$.cookie ("MySkin");//Get the value of a cookie
if (Cookie_skin) {
Cssskin (Cookie_skin);
}
});
function Cssskin (skinname) {
$ ("#" +skinname). AddClass (' selected ')
. siblings (). Removeclass (' selected ');
$ ("#cssfile"). attr (' href ', ' css/' +skinname+ '. css ');
$.cookie ("MySkin", Skinname, {path: '/', expires:10});
}
</script>
</body>

Web page becomes skin tone

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.