1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5 <title>通过js设置css样式</title> 6 7 </head> 8 <body> 9 <input type="button" value="隐藏p标签" onclick="disP()"/> 10 <p> 11 今天晚上好好预习jQuery,预计从明天开始会上5次基础的jQuery 12 </p> 13 <script type="text/javascript"> 14 function disP(){ 15 document.getElementsByTagName("p")[0].style.display="none"; 16 //document.getElementsByTagName("p")[0].style.color="red"; 17 } 18 </script> 19 </body> 20 </html>
时间: 2024-10-21 07:42:36