setinterval says not defined function but it is

前端 未结 1 1569
走了就别回头了
走了就别回头了 2021-01-24 08:56

i have this function which i define inside HEAD:



        
相关标签:
1条回答
  • 2021-01-24 09:11

    Put your code in an separate <script> tag. As soon as a <script> tag has a src attribute, any content of that tag is ignored in favor of the given resource. so just do this:

    <script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
    <script>
    function live() {
        $.get("http://mydomain.com/script.php", function(data){
            var timer = data;
            var elm = document.getElementById("live");
            if (timer == 1){
             elm.style.display = 'block';
            } else{
             elm.style.display = 'none';
            }     
        });
    }
    </script>
    
    0 讨论(0)
提交回复
热议问题