<!DOCTYPE html>
<html>
<head>
<script src="jquery.js"></script>
<script>
$(document).ready(function(){
$("#btn1").click(function(){
alert("p1 Background color = "+$("#p1").css("background-color"));
alert("p2 Background color = "+$("#p2").css("background-color"));
alert("p3 Background color = "+$("#p3").css("background-color"));
});
$("#btn2").click(function(){
$("p").css("background-color","yellow");
});
$("#btn3").click(function(){
$("p").css("background-color","red");
});
$("#btn4").click(function(){
$("p").css("background-color","blue");
});
$("#btn5").click(function(){
$("p").css({"background-color":"yellow","font-size":"200%"});
});
});
</script>
</head>
<body>
<h2>标题</h2>
<p id="p1" style="background-color:#ff0000">这是p1段落。</p>
<p id="p2" style="background-color:#00ff00">这是p2段落。</p>
<p id="p3" style="background-color:#0000ff">这是p3段落。</p>
<button id="btn1">返回p1,p2,p3元素的背景颜色</button>
<button id="btn2">设置p1,p2,p3元素的背景颜色为黄色</button>
<button id="btn3">设置p1,p2,p3元素的背景颜色为红色</button>
<button id="btn4">设置p1,p2,p3元素的背景颜色为蓝色</button>
<button id="btn5">设置p1,p2,p3元素的多种样式</button>
</body>
</html>
<html>
<head>
<script src="jquery.js"></script>
<script>
$(document).ready(function(){
$("#btn1").click(function(){
alert("p1 Background color = "+$("#p1").css("background-color"));
alert("p2 Background color = "+$("#p2").css("background-color"));
alert("p3 Background color = "+$("#p3").css("background-color"));
});
$("#btn2").click(function(){
$("p").css("background-color","yellow");
});
$("#btn3").click(function(){
$("p").css("background-color","red");
});
$("#btn4").click(function(){
$("p").css("background-color","blue");
});
$("#btn5").click(function(){
$("p").css({"background-color":"yellow","font-size":"200%"});
});
});
</script>
</head>
<body>
<h2>标题</h2>
<p id="p1" style="background-color:#ff0000">这是p1段落。</p>
<p id="p2" style="background-color:#00ff00">这是p2段落。</p>
<p id="p3" style="background-color:#0000ff">这是p3段落。</p>
<button id="btn1">返回p1,p2,p3元素的背景颜色</button>
<button id="btn2">设置p1,p2,p3元素的背景颜色为黄色</button>
<button id="btn3">设置p1,p2,p3元素的背景颜色为红色</button>
<button id="btn4">设置p1,p2,p3元素的背景颜色为蓝色</button>
<button id="btn5">设置p1,p2,p3元素的多种样式</button>
</body>
</html>