Để xóa văn bản, dùng remove(). Dùng filter để lấy nội dung không trong thẻ phần tử.
Giả sử HTML:
This is also Demo ProgramDemo Program
Cần xóa "This is also Demo Program" vì nó không nằm trong thẻ. Mã dùng filter() và remove():
Ví dụ
Document This is also Demo ProgramDemo Program
Chạy: lưu file anyName.html(index.html), chuột phải chọn "Open with Live Server" trong VS Code.
Kết quả
Kết quả đầu ra:
