JS控制DIV,淡出效果实例应用(聊天表情的淡出选择)

本文介绍了一个简单的表情选择器实现方案,通过JavaScript控制显示与隐藏,调整透明度,并将选中的表情插入到输入框中。该方案适用于网页聊天应用等场景。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<div id="emotLayer" style="display: none;position:absolute; filter: alpha(opacity=0); width:60%;"  ShowState="0" onclick="return CloseFace();" class="faceDiv">

                    <table width="100%" border="0" cellpadding="2" cellspacing="2" >

  <tr>

    <td><a onclick="return GetFace('8o|')"><img src="images/faces/01.gif" width="19" height="19"></a></td>

    <td><a onclick="return GetFace('$P')"><img src="images/faces/02.gif" width="19" height="19"></a></td>

    <td><a onclick="return GetFace('(*z)')"><img src="images/faces/03.gif" width="19" height="19"></a></td>

    <td><a onclick="return GetFace('(zz)')"><img src="images/faces/04.gif" width="19" height="19"></a></td>

    <td><a onclick="return GetFace('*P')"><img src="images/faces/05.gif" width="19" height="19"></a></td>

    <td><a onclick="return GetFace('*xD')"><img src="images/faces/06.gif" width="19" height="19"></a></td>

    <td><a onclick="return GetFace('*xp')"><img src="images/faces/07.gif" width="19" height="19"></a></td>

    <td><a onclick="return GetFace('*zz')"><img src="images/faces/08.gif" width="19" height="19"></a></td>

    <td><a onclick="return GetFace('++(')"><img src="images/faces/09.gif" width="19" height="19"></a></td>

    <td><a onclick="return GetFace('++|')"><img src="images/faces/10.gif" width="19" height="19"></a></td>

  </tr>



 </table>

                </div>

 

  function ShowFace()

   {



var textDiv=document.all("textDiv");  

     emotLayer.style.left=textDiv.style.left;

  emotLayer.style.top=textDiv.style.top;           

            

             if(emotLayer.ShowState=="1")

         {     

        

               if(emotLayer.filters.Alpha.opacity>20)

               {

                  setTimeout("ChangeMinusAlpha()", 100);

               }

               else

               {

                  emotLayer.style.display="none";

                  emotLayer.ShowState="0";

               }

         }

            else if(emotLayer.ShowState=="0")

            {

          

              if(emotLayer.filters.Alpha.opacity<80)

               {

                  emotLayer.style.display="";

                  setTimeout("ChangePlusAlpha()", 100);

               }

              else

               {

 

                  emotLayer.ShowState="1";

               }

            }

     

   }

   

   function CloseFace()

   {

     emotLayer.style.display = "none" ;

   }

   

   function GetFace(sFace)

   {

     

      //form1.txtMessage.value += sFace; 

      document.getElementById('txtMessage').value += sFace;

      

      

      CloseFace();

   }

   

   function ChangeMinusAlpha()

    {

    var TreeDiv=document.all("emotLayer");

    TreeDiv.filters.Alpha.opacity =TreeDiv.filters.Alpha.opacity-20;

    ShowFace();

    }

    

    function ChangePlusAlpha()

    {

    var TreeDiv=document.all("emotLayer");

    TreeDiv.filters.Alpha.opacity =TreeDiv.filters.Alpha.opacity+20;

    ShowFace();

    }

 

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值