Skip to content
Advertisement

Tag: w3c

Closest ancestor matching selector using native DOM?

Is anybody working on a jQuery.closest() equivalent in the DOM api? Looks like the Selectors Level 2 draft adds matches() equivalent to jQuery.is(), so native closest should be much easier to write. Has adding closest() to Selectors come up? Answer See the element.closest() documentation. Implementing such function with Element.matches() seems not optimal in terms of performance, cause apparently matches() will

Alternative for innerHTML?

EDIT: WOW. This question is 12 years old now. As someone stated, it can be done with a one-liner since 2016: https://stackoverflow.com/a/69322509/80907 The original: I’m wondering if there’s a way to change the text of anything in HTML without using innerHTML. Reason I’m asking is because it’s kinda frowned upon by the W3C. I know it’s nitpicking, but I just

Advertisement