标签:utf-8 script rev class lan set 案例 tle type
1 <!doctype html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Document</title> 6 7 </head> 8 <body> 9 <div> 10 <ul> 11 <li>123</li> 12 <li>123</li> 13 <li>123</li> 14 <li id="four">第四个li</li> 15 <li>123</li> 16 <li>123</li> 17 <li>123</li> 18 <li>123</li> 19 <li>123</li> 20 <li>123</li> 21 </ul> 22 </div> 23 <script> 24 let li_4 = document.getElementById(‘four‘); 25 li_4.previousElementSibling.style.backgroundColor = ‘pink‘; 26 li_4.nextElementSibling.style.backgroundColor = ‘red‘; 27 </script> 28 </body> 29 </html>
element.nextElementSibling与element.previousElementSibling案例
标签:utf-8 script rev class lan set 案例 tle type
原文地址:https://www.cnblogs.com/ustc-yy/p/12073184.html