<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><metahttp-equiv="X-UA-Compatible"content="IE=edge"><metaname="viewport"content="width=device-width, initial-scale=1.0"><title>Document</title><scriptsrc="./jquery-3.6.0.js"></script><style>div,p{width: 100px;height: 100px;margin-top: .625rem;}</style></head><body><p>hello <ahref="">John</a>,how are you doning</p></body><script>$(function(){// 除了a标签,其他的都加上b标签//.contents()不接受任何参数,获取所有子节点,过滤节点为文本节点nodeType$("p").contents().filter(function(){returnthis.nodeType!=1;//当为元素节点为1}).wrap("<b/>")//wrap外层加上标签})</script></html>