To put it simple…
I have element clone. Its div with some other tags saved in it. It also have .x in it.
I need to remove it and then apped that modified element to another element.
Unfortunately, it doesn’t work. Remove failed or something, but .x is still in it.
clone = subtitle.clone(); // Works!
no_label = clone.remove('.x'); // This fails.
more_subtitles.append(no_label); // Its appends no_label, but it still contains .x element.
That’s because remove() removes the matched elements from the DOM. Even if you pass a selector, it’s only used to filter these elements. In your code,
clonematches a single element (the cloned subtitle) which doesn’t expose thexclass.You can use find() to match the
.xelement: