Jquery点击,循环切换Class的效果
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Jquery点击,循环切换Class的效果相关的知识,希望对你有一定的参考价值。
<!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=gb2312" />
<title>点击BOX循环切换颜色</title>
<style>
* margin:0; padding:0;
.blue background-color:#0066FF;
.red background-color:#FF0000;
.green background-color:#00FF00;
.box width:300px; height:300px; border:1px solid #ddd; color:#fff; font-size:28px;
</style>
</head>
<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<body>
<div class="box blue">蓝色</div>
<p>点击BOX内,添加.red样式,BOX内文字变为“红色”。再点击,添加.green样式,文字变为“绿色”。再次点击,又变回.blue样式,文字变为蓝色,依次循环。</p>
<script>
$(function()
$(".box").click(function()
);
);
</script>
</body>
</html>
idx = 0,
colors = [['blue','蓝色'],['red','红色'],['green','绿色']];
div.onclick = function()
idx += 1;
idx = (idx > colors.length - 1) ? 0 : idx;
this.className = '';
this.className = 'box ' + colors[idx][0];
this.innerHTML = colors[idx][1];
;本回答被提问者和网友采纳
jQuery演示10种不同的切换图片列表动画效果
经常用到的图片插件演示jQuery十种不同的切换图片列表动画效果
实例代码下载
<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>jQuery十种不同的切换图片列表动画效果</title>
<meta name="description" content="Animations for Thumbnail Grids: Transition Inspiration for Thumbnail Grids" />
<meta name="keywords" content="animation, thumbnail, grid, css, inspiration, transition, effect, web design" />
<link rel="stylesheet" type="text/css" href="css/demo.css" />
<link rel="stylesheet" type="text/css" href="css/component.css" />
<script src="js/modernizr.custom.js"></script>
</head>
<body>
<div class="container">
<!-- Top Navigation -->
<header>
<h1>Animations for Thumbnail Grids</h1>
<nav class="sucaihuo-demos">
<a class="current-demo" href="index.html">Fall</a>
<a href="index2.html">Slide</a>
<a href="index3.html">Rotate Fall</a>
<a href="index4.html">Rotate Scale</a>
<a href="index5.html">Stack</a>
<a href="index6.html">3d Flip</a>
<a href="index7.html">Bring back</a>
<a href="index8.html">Superscale</a>
<a href="index9.html">Center Flip</a>
<a href="index10.html">Front Row</a>
</nav> 下载
</header>
<section class="tt-grid-wrapper">
<ul class="tt-grid tt-effect-fall tt-effect-delay">
<li><a href="#"><img src="img/1.jpg" alt="img1"/></a></li>
<li><a href="#"><img src="img/2.jpg" alt="img2"/></a></li>
<li><a href="#"><img src="img/3.jpg" alt="img3"/></a></li>
<li><a href="#"><img src="img/4.jpg" alt="img4"/></a></li>
<li><a href="#"><img src="img/5.jpg" alt="img5"/></a></li>
<li><a href="#"><img src="img/6.jpg" alt="img6"/></a></li>
</ul>
<nav>
<a class="tt-current"></a><a></a><a></a><a></a>
</nav>
</section>
</div><!-- /container -->
<script src="js/classie.js"></script>
<script src="js/thumbnailGridEffects.js"></script>
<script type="text/javascript" src="/static/js/home.js"></script>
</body>
</html>
以上是关于Jquery点击,循环切换Class的效果的主要内容,如果未能解决你的问题,请参考以下文章