jquery怎么获取整个<DIV>...</DIV>包涵中的所有代码

来源:互联网 发布:java session生命周期 编辑:程序博客网 时间:2024/04/28 22:20

jquery怎么获取整个<DIV>...</DIV>包涵中的所有代码

比如:获取红色部分<div id="test" style="background-color:red;100px; height:100px;"><h2 style="color:white;">Test</h2></div> 


<html><script src="http://code.jquery.com/jquery-latest.js"></script> <script> $(document).ready(function(){     //alert($(document.body).html());//获取包括div的内容     alert($("#test").html());        //仅获取div下级内容 }); </script> <body>    <div id="test" style="background-color:red;100px; height:100px;"><h2 style="color:white;">Test</h2></div> </body> </html> 


0 0