I'm trying to translate this jQuery into JavaScript, to save a bit on load time. Here's the line of jQuery:
$('div.annotated p > span.citation').parent().css('display', 'inline')
And here's what I have so far in JavaScript:
document.querySelectorAll('div.annotated p > span.citation').forEach((el) => {})
I'm stuck on how to find the parent of an element, and also apparently how to set the CSS for that element. Should I stick with jQuery, or can JavaScript also do this, and is it much harder?
parentmyself. I preferclosest(selector)as it's flexible if your structure changes. Either way, the docs are where you should be looking: developer.mozilla.org/en-US/docsdocument.querySelectorAll('div.annotated p > span.citation').forEach((el) => {el.parentElement.style.display = 'inline'})