码迷,mamicode.com
首页 > Web开发 > 详细

jQuery 操作CSS

时间:2016-06-12 08:24:03      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:

<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<script src="jquery-2.2.4.min.js"></script>
		<script>
			$(window).load(function() {
				var myDiv = $(‘div‘)
				//添加CSS样式
				myDiv.css({
					‘width‘: ‘200px‘,
					‘padding‘: ‘20px‘,
					‘height‘: ‘200px‘,
					‘background‘: ‘red‘,
					‘border‘:"4px solid green",
				})
				//查看盒子相关属性,高度,宽度,
				alert("heigt:" + myDiv.height());
				alert("Interheigt:" + myDiv.innerHeight());
				alert("Outterheigt:" + myDiv.outerHeight());
				
				alert("offsetLeft:" + myDiv.offset().left + "right:"+myDiv.offset().right);

			});
		</script>
	</head>

	<body>
		<div></div>
	</body>

</html>

  

jQuery 操作CSS

标签:

原文地址:http://www.cnblogs.com/yqlog/p/5576457.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!