简体   繁体   中英

Javascript Function to hover over element?

I know we can click buttons with click() in console, but how do you hover over an element to reveal the tooltip that comes up when you hover your mouse over the icon?

You can use onmouseover() Check out some DOM event handlers https://www.w3schools.com/js/js_htmldom_events.asp

The mouseover event occurs when the mouse pointer is over the selected element.

The mouseover() method triggers the mouseover event or attaches a function to run when a mouseover event occurs.

 <div onmouseover="mOver(this)" onmouseout="mOut(this)" style="background-color:#D94A38;width:120px;height:20px;padding:40px;"> Mouse Over Me</div> <script> function mOver(obj) { obj.innerHTML = "Thank You" } function mOut(obj) { obj.innerHTML = "Mouse Over Me" } </script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM