w3school: what is "this"?

Please, I appologise, but what exactly is menaing “this” in front of inner…in this code:

<!DOCTYPE html>
<html>
<body>

<h1 onclick="this.innerHTML='Ooops!'">Click on this text!</h1>

</body>
</html>

Many thanks!

If you’re really interested in learning javascript, then you really ought to stop using w3schools for your education.
For example, that code uses inline javascript. Not best practice for quite a while now.

Anyway, “this” pretty much means what common sense suggests it means. You can read about it in this much better (compared to w3schools) site https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this

It basically means “change the text of this element to ‘Ooops!’ when it’s clicked on”.

As said, though, it’s lousy code, so don’t use it, but read the reference supplied instead. :slight_smile: