使用 onmousemove 事件處理函數來動態響應鼠標移動 (使用onmousemove事件來顯示按鈕圖片)
點我functionshowButton,獲取鼠標相對圖像的位置varrect=image.getBoundingClientRect,varx=event.clientX,rect.left,vary=event.clientY,rect.top,檢查鼠標光標是否位于圖像的中心區域if,x,=image.width,...。
技術教程 2024-09-15 06:24:55