Sublime Text
<!DOCTYPE html> <html> <head> <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.12.0.min.js"></script> <script> $(document).ready(function(){ $("span").parent("li").attr("style","border:5px solid red;"); }) </script> <style type="text/css"> body * { border:1px solid black; list-style-type: none; margin:10px; padding:5px; display:block; } </style> </head> <body> <div>Phần tử cấp 1 <ul>Phần tử cấp 2 <li>Phần tử cấp 3 <span>Phần tử cấp 4</span> </li> </ul> </div> <br> <div>Phần tử cấp 1 <div>Phần tử cấp 2 <p>Phần tử cấp 3 <span>Phần tử cấp 4</span> </p> </div> </div> </html>
<!DOCTYPE html> <html> <head> <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.12.0.min.js"></script> <script> $(document).ready(function(){ $("span").parent("li").attr("style","border:5px solid red;"); }) </script> <style type="text/css"> body * { border:1px solid black; list-style-type: none; margin:10px; padding:5px; display:block; } </style> </head> <body> <div>Phần tử cấp 1 <ul>Phần tử cấp 2 <li>Phần tử cấp 3 <span>Phần tử cấp 4</span> </li> </ul> </div> <br> <div>Phần tử cấp 1 <div>Phần tử cấp 2 <p>Phần tử cấp 3 <span>Phần tử cấp 4</span> </p> </div> </div> </html>