remove()はセレクターのタグが削除されます。
empty()は中にあるタグが削除されましたが、removeは自分が削除されます。
<div class="hello">hello world</div>
上のHTMLソースにあるdivタグが削除されるのをremove()がします。
.hello{border:3px solid yellow}
タグがなくなるのをみるためCSSを適用します。
$('.hello').remove();
<!doctype html> <html> <head> <meta charset="utf-8" /> <title>EVERDEVEL :: jQuery</title> <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.0.min.js" ></script> <script> $(function(){ $('.hello').remove(); }); </script> <style> .hello{border:3px solid yellow} </style> </head> <body> <div class="hello">hello world</div> </body> </html>
ご覧くださってありがとうございます。お問い合わせと間違い説明はある場合、下にあるコメントにお願いいたします。
//=$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']?>コメント 0個
並べ替え