如何使用JQuery删除Div的内容.例如.
<div id="1">
<label id="label1"/><br/>
<input type="text" data-attr="phoneEuro" style="width: 200px;" id="input1"/> <label id="instr1"/>
</div>
Run Code Online (Sandbox Code Playgroud)
我想删除Div的全部内容.并向其添加新内容.
Jas*_*son 10
$("#1").html("");
Run Code Online (Sandbox Code Playgroud)
要不就
$("#1").html("your new content");
Run Code Online (Sandbox Code Playgroud)
将id更改为以字母开头
首先,根据规范,id必须以字母开头.
<div id="myDiv">
<label id="label1"/><br/>
<input type="text" data-attr="phoneEuro" style="width: 200px;" id="input1"/> <label id="instr1"/>
</div>
$('#myDiv').html('your new content');
Run Code Online (Sandbox Code Playgroud)
如果使用html方法,则可以简单地覆盖现有的DIV内容.
$(document).ready(function()
{
$('div#one').children().remove();
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
78941 次 |
| 最近记录: |