jquery样式

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>样式</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <!-- 记得引入jquery-1.11.3.js文件到js目录下 -->
    <script type="text/javascript" src="js/jquery-1.11.3.js"></script>
    <style type="text/css">
    	body{
    		font-family: "Microsoft YaHei"
    	}
    	.cGreen{color: #4CA902}
    	.cPink{color: #ED4A9F}
    	.cBlue{color: #0092E7}
    	.cCyan{color: #01A6A2}
    	.cYellow{color: #DCA112}
    	.cRed{color: #B7103B}
    	.cPurple{color: #792F7C}
    	.cBlack{color: #110F10}
    	.cOrange{color: #FF4500}
    	.cGray{color: #A9A9A9}
    	.hide{display: none;}
    	span {
    		float:left;
    	}
    	ul li {
    		width:120px;
    		float: left;
    		margin-left: 10px;
    	}
    	.fBold{font-weight: bold;}
    </style>
    <script type="text/javascript">
    
    	$(document).ready(function(){
    		$("#btn1").click(function(){
    			$("#usa").addClass("cOrange");
    		});
    		$("#btn2").click(function(){
    			$("#usa").removeClass("cOrange");
    		});
    		$("#btn3").click(function(){
    			$("#usa").toggleClass("cOrange");
    		});
    		
    		$("#btn4").click(function(){
    			console.log( $("#chn").hasClass("fBold") );
    		});
    		$("#btn5").click(function(){
    			$("#usa").css({"font-weight":"bold","color":"blue"});
    		});
    		$("#btn6").click(function(){
    			console.log( $("li").height() );
    			$("li").height(30);
    			console.log( $("li").height() );
    		});
    		$("#btn7").click(function(){
    			
    		});
    		$("#btn8").click(function(){
    			// offset()查看广州和洛杉矶的相对位置
    			console.log( $("#gz").offset().left + " " +  $("#gz").offset().top );
    			console.log( $("#la").offset().left + " " +  $("#la").offset().top );
    		});
    	});
    </script>
    
  </head>
  
  <body>
  	<span>中国城市</span>:<br>
    <ul id="chn" class="fBold cOrange">
    	<li id="bj">北京</li>
    	<li id="sh">上海</li>
    	<li id="gz">广州</li>
    	<li id="sz">深圳</li>
    	<li id="hk">香港</li>
    </ul>
    <br><br>
    <span>美国城市</span>:<br>
    <ul id="usa">
    	<li id="wst">华盛顿特区</li>
    	<li id="ny">纽约</li>
    	<li id="la">洛杉矶</li>
    	<li id="scg">芝加哥</li>
    </ul>
    <br><br>
    <span>德国城市</span>:<br>
    <ul id="ger">
    	<li id="mnh">慕尼黑</li>
    </ul>
    <div style="clear:both;"></div>
    <br><br>
    <hr>
    <input type="button" id="btn1" value="addClass()为美国城市添加cOrange类">
    <input type="button" id="btn2" value="removeClass()为美国城市去除cOrange类">
    <input type="button" id="btn3" value="toggleClass()为美国城市添加或去除cOrange类">
    <input type="button" id="btn4" value="hasClass()判断中国城市是否有fBold类">
    <input type="button" id="btn5" value="css()将美国的城市字体加粗和颜色设置为蓝色">
    <input type="button" id="btn6" value="height()查看城市(li元素)的高度并设置高度后再查看设置后值 ">
    <input type="button" id="btn7" value="width()查看城市(li元素)的宽度并设置宽度后再查看设置后值">
    <input type="button" id="btn8" value="offset()查看广州和洛杉矶的相对位置">
  </body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值