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
Tag: w3c
Using HTML tags in JavaScript strings while complying with W3C rules
Here’s my code: The W3C Markup Validator doesn’t like this. It doesn’t want HTML tags inside my JavaScript code. Here’s the error message it produces if I attempt this: character “<” is the first character of a delimiter but occurred as data How can I fix this while making sure that my page doesn’t mess up if I pass the
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