菜单切换
FACESOHO知行者
心灵
记录
远方
赞赏工具
源代码:
点击运行
保存
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>小鸟启蒙(facesoho.com)</title> <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"> </script> <script> $(document).ready(function(){ $("button").click(function(){ $("div").contents().filter("em").wrap("<b/>"); }); }); </script> </head> <body> <div><em>Hello world! What a beautiful day!</em></div> <p>在这个实例中,通过点击按钮,我们查找到所有div元素内得文本节点,并且使用b元素包裹它们。</p> <button>查找所有文本节点并且包裹它们</button><br> </body> </html>
运行结果