Reputation: 692
I have the following js code:
changeVideo(element) {
const currentVideo = document.querySelector('.current-video');
const nextVideo = document.querySelector(`${element}`);
if (currentVideo === nextVideo) {
return;
}
// more code here
}
Is this the correct/proper way to compare DOM Elements? (currentVideo === nextVideo)
The expectation is for this to work in all modern browsers.
Upvotes: 1
Views: 2060
Reputation: 194
I guess after almost 2 years the problem has been solved... but for future searches, you can use Node.isEqualNode() for more information go to MDN on the subject
Upvotes: 2