$('#id').点击功能不起作用

anj*_*ash 0 html javascript jquery

它在localhost上完美运行,但它在服务器上不起作用.

当我点击"开始免费试用"锚文本时,它不起作用.警报未显示.可能是什么问题呢?

<script>
 $(function() {
        $('#activator3').click(function(){
            alert('huan');
            $('#overlays3').fadeIn('fast',function(){
                $('#boxs3').animate({'top':'80px'},500);
            });
        });
        $('#boxclose3').click(function(){
            $('#boxs3').animate({'top':'-500px'},500,function(){
                $('#overlays3').fadeOut('fast');
            });
         });

    });
</script>

<a href="javascript:void(0)" style="" class="activator3" id="activator3">
<div id="indexpack2" style="">Start Free Trial</div>
</a>
Run Code Online (Sandbox Code Playgroud)

这是小提琴


注意

我试过了:

  1. 添加document.ready()包装脚本 - 不工作

  2. $('#activator3').on('click', function(){}); - 不工作

任何帮助,将不胜感激.

mau*_*are 5

我认为你缺少Jquery参考.在您的文件中包含以下代码.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
Run Code Online (Sandbox Code Playgroud)