Returns true if the Element(s), EventTarget(s), or CSS selector(s) specified as left and the Element, EventTarget, or CSS selector specified as right do match.
left
right
One or many Element, EventTarget, or CSS selectors to check; if an array, returns true if one of the elements matches the target element input.
Element, EventTarget, or CSS selector to compare against.
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")!;areElementsSame(item1, item2);// falseareElementsSame(item1, "#item-1");// trueareElementsSame(item1, null);// false Copy
const item1 = findElement("#item-1")!;const item2 = findElement("#item-2")!;areElementsSame(item1, item2);// falseareElementsSame(item1, "#item-1");// trueareElementsSame(item1, null);// false
Returns true if the Element(s), EventTarget(s), or CSS selector(s) specified as
left
and the Element, EventTarget, or CSS selector specified asright
do match.