jQuery添加\删除元素
html>
jquery添加和删除元素
$(function(){
//添加元素
//元素内部添加
//append()在被选元素的结尾插入内容;
//$('button').click(function(){
//$('div').append('
//})
//prepend()在被选元素的开头插入内容;
//$('button').click(function(){
//$('div').prepend('
123
')
//})
//元素外部添加
//after()在被选元素之后插入内容;
//$('button').click(function(){
//$('div').after('
点击
')
//})
//before()在被选元素之前插入内容;
//$('button').click(function(){
//$('div').before('
123
')
//})
//删除元素:
//remove()方法删除被选元素及其子元素;
//$('button').click(function(){
//$('div').remove()
//})
//empty()方法删除被选元素的子元素;
$('button').click(function(){
$('div').empty()
})
})
*{margin:0;padding:0;}
.div{width:600px;margin:20pxauto;text-align:center;padding:10px;border:1pxsolid#ccc;}
.text{height:50px;line-height:50px;background:#9BF25A;margin-bottom:10px;}
点击
任务
?不会了怎么办