1、问题:P标签嵌套P标签时出现错误
案发现场:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <div> <p>p1</p> <p><p>p2</p></p> </div> <p>p3</p> </body> <script src="jquery-1.8.3.min.js"></script> <!-- <script src="jquery-1.9.1.min.js"></script> --> <script type="text/javascript"> $(function(){ $("div > p").css({ "color": "red", }) }); </script> </html>
结论:p标签里面不能嵌套块级元素。
验证:通过
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style> *{ color: red; } </style> </head> <body> <div> <span>span1</span> <span> span2 <span>span3</span> </span> </div> </body> <script src="jquery-1.8.3.min.js"></script> <!-- <script src="jquery-1.9.1.min.js"></script> --> <script type="text/javascript"> $(function(){ $("div > span").css({ "color": "blue", }) }); </script> </html>
版权声明:除特别声明外,本站所有文章皆是本站原创,转载请以超链接形式注明出处!