Why jQuery does not work on my home (local) machine?

前端 未结 6 1927
失恋的感觉
失恋的感觉 2020-11-30 12:56

My question isn\'t so much about why a specific bit of jQuery I\'ve written isn\'t working as it is about no jQuery at all is working; not even working examples I\'ve copied

相关标签:
6条回答
  • 2020-11-30 13:28

    The code is ok.

    The script is not downloading because, as you probably are not deploying the code, the browser will default to the file:// protocol.

    To solve it, add the http: at the script tag:

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js">
                                                                               </script>
    
    0 讨论(0)
  • 2020-11-30 13:32

    Use http:

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
    
    0 讨论(0)
  • 2020-11-30 13:34

    You forgot to place the

    $('p').text('New Stuff');
    

    inside document ready for that you can do like this:

    $(function(){
       $('p').text('New Stuff');
    });
    
    0 讨论(0)
  • 2020-11-30 13:38

    The way you load jQuery might be a problem. When you start your URL with // it is supposed to work when page is being browsed via HTTP or HTTPS protocols. However, if you will open it as a local file it won't work.

    Given that your example works over HTTP I suggest you try to include jQuery as following:

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js">
    </script>
    
    0 讨论(0)
  • 2020-11-30 13:44

    change this

    <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
    

    to this

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
    
    0 讨论(0)
  • 2020-11-30 13:47

    Check if you have the proper permission to the script by invoking the script location in the browser url. So, if you have just put the "http://someloaction/js/jquery.min.js" in the browser url. If you can see "forbidden", permissions are ok.

    0 讨论(0)
提交回复
热议问题