Uncaught TypeError: Cannot read property 'alpha' of undefined 报错解决
生活随笔
收集整理的這篇文章主要介紹了
Uncaught TypeError: Cannot read property 'alpha' of undefined 报错解决
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
先附上報錯的代碼:
<!DOCTYPE html> <html lang="en"> <head><meta charset="UTF-8"><title>動態改變圖片的焦點</title> </head> <body> <script type="text/javascript"> function visible(cursor,i) {if(i==0)cursor.filters.alpha.opacity=100;elsecursor.filters.alpha.opacity=50; } </script> <table border="0" cellspacing="0" cellpadding="0"><tr><td align="center"><img src="images/3.jpg" border="0" style="filter:alpha(opacity=100)" onMouseOver="visible(this,1)" onMouseOut="visible(this,0)" width="148" HEIGHT="148"></td></tr> </table> </body> </html>然后調試的時候就出現了這樣的錯誤:
alpha沒有定義。
這樣解決:
把代碼中的:
cursor.filters.alpha.opacity=100;改為:
cursor.style.opacity=1;完美解決問題。
總結
以上是生活随笔為你收集整理的Uncaught TypeError: Cannot read property 'alpha' of undefined 报错解决的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 30天150万公里,韦布望远镜抵达终点成
- 下一篇: jpg怎么转换jpeg?一招教你轻松完成