<!DOCTYPE html> <html> <head> <!--实现给段落的标签添加背景颜色--> <meta charset="utf-8"> <title>jQuery</title> <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("button").click(function(){ $("p#p_id1").css("background-color","red"); $("p#p_id2").css("background-color","blue"); }); }); </script> </head> <body> <h2>点击</h2> <p id="p_id1">1234</p> <p id = "p_id2">56789</p> <button>点击按钮</button> </body> </html>
原文地址:https://www.cnblogs.com/zxrxzw/p/10821089.html
时间: 2024-10-05 09:50:35