How would you make the element react when the mouse moves into it?

<h1 id="title" onclick="mouseenter('hello');" >Hello</h1>

<mouseenter id="title" onclick="alert('hello');" >Hello</mouseenter>

<h1 id="title" onmouseenter="alert('hello');" >Hello</h1>

<h1 id="mouseenter" onclick="alert('hello');" >Hello</h1>

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

Do you have a question? It looks like you’ve just pasted in a chunk of code.

The onmouseenter event is what you want (your third line).

1 Like