jQuery的css()方法
下面的代码可以为div一次性设置多个样式属性
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>css3</title>
<script src="js/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#AB").css({
color:"red",
fontSize:"16px",
fontWeight:"bold"
});
});
</script>
</head>
<body>
<div id="AB">00H5</div>
</body>
</html>
当然也可以单个设置CSS样式如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS</title>
<script src="js/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#AB").css("color","red");
});
</script>
</head>
<body>
<div id="AB">00H5</div>
</body>
</html>
时间: 2024-10-11 10:48:09