Jquery学习之旅之动态设置css属性和获取css属性

来源:互联网 发布:linuxmint优化 编辑:程序博客网 时间:2024/06/05 16:03
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style type="text/css">
*{
  font-size:24px;
  font-family: "微软雅黑";
}
.anii{width:100px;height:60px;background-color: red;position: absolute;}
</style>
</head>
<body>
<table border="2px solid black">
<tr><th>one</th></tr>
</table>
<button id="addClass">addClass</button>
<button id="removeClass">removeClass</button>
<button id="adjustcss">adjustcss</button>
<p>Hello,World<p>


 <script type="text/javascript" src="jquery/jquery-2.1.1.js"></script>
<script type="text/javascript" src="jquery/jquery-2.1.1.min.js"></script>
<script type="text/javascript">
 $(document).ready(
   function()
   { 
    $("#addClass").click(function(){$("p").addClass("anii");});
    $("#removeClass").click(function(){$("p").removeClass("anii");});
    $("#adjustcss").click(function(){$(".anii").css("background-color","yellow");});
   }
 );
</script>
</body>
</html>
0 0
原创粉丝点击