What js code instead of this jquery code?

Since @MaxZieb asked me not use jquery anymore, I’m doing my best. :wink:
But now I run into a problem.
How should I write
$(".text, .text2").html(“blabla”)
in JS?
I need to use it in something like this example file:
Untitled6.6.zip (79.3 KB)

In vanilla JavaScript you would use innerHTML to set the value.

document.querySelector('.text').innerHTML = 'blablabla';

To set two selectors or all occurrences you would do something like this

document.querySelectorAll('.text, .text2').forEach(function(node){
	node.innerHTML = 'blablabla';

That’s great Max. Thank you.
The ‘querySelector’ I have used, no problem.
I didn’t know the ‘forEach’
Learn something new every day. My motto until I die :grinning:


1 Like