នៅក្នុង jQuery មាន method ពីរគឺ
- remove()
- empty()
remove()
remove method គឺលុបទាំង parent និង child ដែលយើង select តែ parent
$("#test1").remove()
<div class="txt">
<p>Hello jQuery</p>
</div>
<button>click remove</button>
<script>
$(document).ready(function(){
$("button").click(function(){
$('.txt').remove()
})
})
</script>
empty()
empty method គឺលុបតែ child ហើយទុក parent ដែលយើង select តែ parent
$("#test1").empty()
<div class="txt">
<p>Hello jQuery</p>
</div>
<button>click remove</button>
<script>
$(document).ready(function(){
$("button").click(function(){
$('.txt').empty()
})
})
</script>
0 Comments