1. 程式人生 > 其它 >9jquery操作行內樣式

9jquery操作行內樣式

<head>
<meta charset="UTF-8">
<title>3操作行內樣式和class屬性</title>
</head>
<body>
<div class="no1">我是測試語句</div>
<div class="btn">
<input type="button" value="效果1">
<input type="button" value="效果2">
<input type="button" value="效果3">
<input type="button" value="效果3">
</div>
</body>
<script src="js/jquery-1.8.3.js"></script>
<script>
/*多屬性*/
$(".btn :button:eq(2)").on("click",function () {
$(".no1").css("background","red url('image/123.jpeg') no-repeat").css("color","blue")
.css("font-size","1.2rem").css("text-align","center");
})
/*背景顏色*/
$(".btn :button:eq(1)").on("click",function () {
$(".no1").css("background-color","blue")
})
/*字型顏色*/
$(".btn :button:eq(0)").on("click",function () {
$(".no1").css("color","red")
})
</script>