0

当我点击左下角的删除图标时,我试图删除里面的 div 和内容。我怎么能做到这一点?单击 X 时,问题的内容和 div 消失。

这是代码。

<li class="question" id="question2">
    <div class="question-header curves dense-shadows">
        What color is the sky? 
    </div>
    <div class="question-content dense-shadows">
        <ol type="A">
            <li><input type="radio" id="q2a1" name="question2" /> Red</li>
            <li><input type="radio" id="q2a2" name="question2" /> Green</li>
            <li><input type="radio" id="q2a3" name="question2" /> Blue</li>
            <li><input type="radio" id="q2a4" name="question2" /> Brown</li>
        </ol>
        <div style="text-align:right">

            <a href="#" class="delete"><span style="margin-left:5px;"><img src="images/deletebutton.png" 
                onmouseover="this.src='images/deletebuttonhover.png'" onmouseout="this.src='images/deletebutton.png'" title="Delete" alt="delete"/></span></a>
        </div>
    </div>
</li>
4

2 回答 2

1
<a href="#" class="delete" onclick="document.body.removeChild(document.getElementById('question2'))">
于 2013-07-27T22:36:05.093 回答
0

尝试使用

yourDivToBeDeleted.innerHTML="";

于 2013-10-17T10:05:45.827 回答