js - DOM -02 parentNode 点击隐藏a让li隐藏
1.
2.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <ul id="ul1"> <li>1111 <a href="javascript:;">隐藏</a></li> <li>2222 <a href="javascript:;">隐藏</a></li> <li>3333 <a href="javascript:;">隐藏</a></li> <li>4444 <a href="javascript:;">隐藏</a></li> </ul> <script> window.onload = function () { var oUl = document.getElementById('ul1'); var aA = document.getElementsByTagName('a'); for (var i = 0; i < aA.length; i++){ aA[i].onclick = function () { this.parentNode.style.display = 'none'; } } } </script> </body> </html>