鼠标单击时的工具提示。代码片段有效,但当嵌入网站时,它不起作用。不知道为什么

问题描述 投票:0回答:0

我有一个全屏的点击区域。单击鼠标时,工具提示出现在鼠标指针附近,移动时消失。代码片段似乎工作正常。但是当我将代码嵌入我的网站时,它会抛出一个错误:$ is not a function. (In '$(document)', '$' is undefined). 不知道为什么。任何帮助将不胜感激。

  $(document).ready(function(){
          
              $('.fullscreen-click-area').click(showBox).mousemove(hideBox);
          
              function showBox(e){
                  $('.tooltip').fadeIn().css(({ left:  e.pageX, top: e.pageY }));
              }
              
              function hideBox(){
                  $('.tooltip').fadeOut();
              }
          });
      .fullscreen-click-area {
          background-color: #7F7F7F;
          position: absolute;
          top: 50%;
          left: 50%;
          transform: translate(-50%, -50%);
          width: 100%;
          height: 100vh;
        }
        
        .tooltip {
            margin:10px;
            padding:12px;
            border:2px solid #000;
            width:60px;
            position: absolute;
            display: none;
            background-color: #fff;
            
        }
<script type="text/javascript" src="http://code.jquery.com/jquery-1.3.2.js"></script>

<div class="fullscreen-click-area"></div>
<div class="tooltip">TOOLTIP</div>

javascript jquery onclick mouseclick-event onmouseclick
© www.soinside.com 2019 - 2024. All rights reserved.