小编moh*_*ati的帖子

如何使用Javascript在html代码中的特殊标记之前和之后删除标记?

我需要使用Javascript删除div中具有“ item”类的所有标签,但一个标签除外<b>

这是我的HTML文档的样子,(我的示例代码):

    <div class="item">
        <a href="sample-href1">
            <div class="result-image">
                <h5 class="result-cat cat-conf wn">test</h5>
            </div>
        </a>
        <h4>1.
            <a href="sample-href2" title="sample-title2">
                <b> goal tag1 (i need just this tag) </b>
            </a>
        </h4>
        <span class="feature">test</span>
        <div class="compact">
            </br>
            <a href="test12" title="test12"> test12 </a>
            <br>
            <b> some text </b>
            <a href="test123" title="test123"> test123 </a> -
            <a href="test147" title="test147" > test147 </a>
            </br>
            <b>11</b>
            another some text
            </br>
        </div>
        <a href="test159" title="test159" class="download"> test </a>
        <div class="clr"></div>
    </div>
    <div class="item">
        <a href="sample-href1968">
            <div …
Run Code Online (Sandbox Code Playgroud)

html javascript

0
推荐指数
1
解决办法
63
查看次数

标签 统计

html ×1

javascript ×1