Checks if the Element(s), EventTarget(s), or CSS selector(s) specified as left and the Element, EventTarget, or CSS selector specified as right do not match.
left
right
One or many Element, EventTarget, or CSS selectors to check; if an array, returns true only if all elements don't match the target element input.
true
Element, EventTarget, or CSS selector to compare against.
true if the elements do not match.
This function doesn't throw if the specified left and/or right elements don't exist. Rather, it just returns false. This was a deliberate choice.
false
HTML
<ul> <li id="item-1">Item 1</li> <li id="item-2">Item 2</li></ul> Copy
<ul> <li id="item-1">Item 1</li> <li id="item-2">Item 2</li></ul>
Code
const item1 = findElement("#item-1")!;const item2 = findElement("#item-2")!;areElementsDifferent(item1, item2);// trueareElementsDifferent(item1, "#item-1");// falseareElementsDifferent(item1, null);// false Copy
const item1 = findElement("#item-1")!;const item2 = findElement("#item-2")!;areElementsDifferent(item1, item2);// trueareElementsDifferent(item1, "#item-1");// falseareElementsDifferent(item1, null);// false
Checks if the Element(s), EventTarget(s), or CSS selector(s) specified as
left
and the Element, EventTarget, or CSS selector specified asright
do not match.