The previous chapter introduced the content:
This section adds the following content:
$().addClass(value); //Add an information value to the class attribute$().removeClass(value); //Delete an information value in the class attribute$().toggleClass(value); //Toggle effect, delete it if it exists, add it if it doesn’t
<!DOCTYPE html>
<html>
<head>
<title>php.cn</title>
<meta charset="utf-8" />
<script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script>
<script>
function f1(){
$("div").addClass('s2');
}
function f2(){
$("div").removeClass('s2');
}
function f3(){
$("div").toggleClass('s2')
}
</script>
<style type="text/css">
.s2{
width:250px;
height:25px;
background: yellow;
}
</style>
</head>
<body>
<div class="s1">欢迎大家学习我们的jQuery课程</div>
<input type="button" value="设置" onclick="f1()" />
<input type="button" value="删除class的属性值" onclick="f2()" />
<input type="button" value="开关class属性值的操作" onclick="f3()" />
</body>
</html>Next Section