问答详情
源自:6-2 [JavaScript]函数声明与表达式

无法实现鼠标的移入移出改变图像焦点

<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=gd2312">
        <title>制作我的第一个网页</title>
    </head>
    <body>
        <h1>标题1</h1>
         <script language="javascript"> 
         function visible(cursor,i)                             <!--设置鼠标移入和移除时图片效果-->        
         {
         if(i==0)                                               
         cursor.filters.alpha.opacity=100;
         else
          cursor.filters.alpha.opacity=30;
             }
    </script>
    <table border="0" cellpadding="0" cellspacing="0">
    <tr>
  
    <img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1505486015084&di=a425a9e7203df8b262e419dcaff9f1ec&imgtype=0&src=http%3A%2F%2Fimgs.focus.cn%2Fupload%2Fty%2F21935%2Fa_219340089.jpg"border="0" style="filter:alpha(opacity=100)" onMouseOver="visible(this,1)" onMouseOut="visible(this,0)" width="148" height="121">
 
    </tr>
    </table>
    </body>
</html>


提问者:慕斯卡5410818 2017-09-15 20:39

个回答

  • 十亿燚
    2017-09-21 17:13:30

             <script language="javascript"> 

             function visible(cursor,i)                             <!--设置鼠标移入和移除时图片效果-->        

             {

                 if(i==0){

                 cursor.style.opacity=1;

                 }                                               

                 else{

                  cursor.style.opacity=0.3;

                 }

             }

            </script>

    //是要这样的效果吗?