8/13/2017

[ javascript ] mouseover and onmouseout event (demo download)

今天要來介紹JS的mouseover event,讓我們一起來看看吧,check it out

我們使用onmouseover指令,然後再使用alert的function
在html中我們寫入
<img src="MyImage" alt="mouse" onmouseover="alert('MouseOverWork!')" />

沒有意外的話當滑鼠移上去就會跳alert視窗了
接下來我們也介紹onmouseout的指令,常常搭配onmouseover一起使用
示範如下
<img src="MyImage" alt="mouse" onmouseout="alert('MouseOutWork!')" />
所以當滑鼠移出圖片,也會跳alert視窗了
當然alert()大家也可以換成自己要使用的function
如果看不懂也沒關係,可以直接從我網站上下載demo回去使用

下載js demo檔案 download here



如果覺得我的文章有幫助
請你點右邊的FB加入訂閱 我會在粉絲團不定期分享新資訊
也歡迎交流!謝謝 阿特底賽粉絲團
https://www.facebook.com/artdesigntw





No comments:

Post a Comment