首页 > 其他 > 详细

addClass的用法和is函数的用法

时间:2016-08-13 12:37:47      阅读:193      评论:0      收藏:0      [点我收藏+]
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $(".box1").toggle(function(){
    $("p:first").addClass(main);//addClass如果增加的样式与前面冲突,则覆盖前面的样式
  },function(){
    $("p:first").removeClass(main);
  });    
    $(".box2").click(function(){
        if($(".intro").is(".main")){//is函数判断是否有类main
            alert(hello);
        }else{
            alert(null);
        }
    }); 
});
</script>
<style type="text/css">
.intro
{
font-size:120%;
color:red;
}
.main
{
font-size:90%;
color:blue;
}
</style>
</head>
<body>
<h1>This is a heading</h1>
<p class="intro">This is a paragraph.</p>
<p>This is another paragraph.</p>
<button class="box1">改变第一个段落的类</button>
<button class="box2">提交</button>
</body>
</html>

 

addClass的用法和is函数的用法

原文:http://www.cnblogs.com/xiaozhumaopao/p/5767598.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!