توضیح:
زمانیکه نشانگر موس از روی المنت و فرزندان آن جابجا شود رویداد آن فراخوانی می شود. این رویداد بهمراه رویداد onmouseover استفاده می شود.
نحوه نوشتن:
در حالت خصوصیت تگ HTML:
1 |
<element onmouseout="myScript"> |
در داخل جاوااسکریپت:
1 |
object.onmouseout = function(){myScript}; |
در قالب متد addEventListener:
1 |
object.addEventListener("mouseout", myScript); |
تگ های پشتیبان کننده:
1 2 |
همه تگ ها بغیر از <base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, <title> |
نسخه پشتیبانی مرورگرها:
مرورگر Chrome | مرورگر Firefox | مرورگر Edge | مرورگر Safari | مرورگر Opera |
---|---|---|---|---|
همگی | همگی | همگی | همگی | همگی |
حالت Bubbles:
بله
حالت Cancelable:
بله
مثال:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <img src="smiley.gif" onmouseover="myfunction(this)" onmouseout="myfunction2(this)"> <script> function myfunction(x){ x.style.width = "64px"; x.style.height = "64px"; } function myfunction2(x){ x.style.width = "32px"; x.style.height = "32px"; } </script> </body> </html> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <img src="smiley.gif"> <script> document.querySelector("img").onmouseover = myfunction; document.querySelector("img").onmouseleave = myfunction2; function myfunction(){ document.querySelector("img").style.width = "64px"; document.querySelector("img").style.height = "64px"; } function myfunction2(){ document.querySelector("img").style.width = "32px"; document.querySelector("img").style.height = "32px"; } </script> </body> </html> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <img src="smiley.gif"> <script> document.querySelector("img").addEventListener('mouseover', myfunction); document.querySelector("img").addEventListener('mouseleave', myfunction2); function myfunction(){ document.querySelector("img").style.width = "64px"; document.querySelector("img").style.height = "64px"; } function myfunction2(){ document.querySelector("img").style.width = "32px"; document.querySelector("img").style.height = "32px"; } </script> </body> </html> |