JavaScript DHTML/jQuery/contents
contents() finds all the child nodes inside the matched elements
<source lang="html4strict">
<html>
<head> <script type="text/javascript" src="js/jquery-1.3.2.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("p").contents().not("[nodeType=1]").wrap("<b/>"); }); </script> </head> <body> <body>
Hello <a href="http://wbex.ru/">wbex</a>asdf
</body>
</html>
</source>
Get tag content
<source lang="html4strict">
<html>
<head> <script type="text/javascript" src="js/jquery-1.3.2.js"></script> <script type="text/javascript"> $(document).ready(function(){ alert($("p").contents().text()); }); </script> </head> <body> <body>
Hello spandata
</body>
</html>
</source>
Wrap tag to another tag
<source lang="html4strict">
<html>
<head> <script type="text/javascript" src="js/jquery-1.3.2.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("p").contents().filter(function(){ return this.nodeType != 1; }).wrap("<b/>"); }); </script> </head> <body> <body>
Hello spandata
</body>
</html>
</source>