linking jquery in html

前端 未结 5 1905
既然无缘
既然无缘 2020-11-27 17:21

I can\'t manage to successfully link jQuery to my html. I have made the most simple jQuery code possible just so I know it\'s right, and I\'ve tried everything I can think o

相关标签:
5条回答
  • In this case, your test.js will not run, because you're loading it before jQuery. put it after jQuery:

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
    <script type="text/javascript" src="test.js"></script>
    
    0 讨论(0)
  • 2020-11-27 18:10

    Seeing the answers I have nothing else to add but one more thing:

    in your test.html file you have written

    link rel="stylesheet" type="css/text" href="test.css"/

    see where you have written

    type="css/text"

    there you need to change into

    type="text/css"

    so it will look like that

    link rel="stylesheet" type="text/css" href="test.css"/

    and in this case the CSS file will be linked to HTML file

    0 讨论(0)
  • 2020-11-27 18:11
    <script
     src="CDN">
    </script>
    

    for change the CDN check this website.

    the first one is JQuery

    0 讨论(0)
  • 2020-11-27 18:12

    I had a similar issue, but in my case, it was my CSS file.

    I had loaded my CSS file before the JQuery library, since my jquery function was interaction with my css file, my jquery function wasn't working. I found this weird, but when I loaded the CSS file after loading the JQuery library, it worked.

    This might not be directly related to the Question, but it may help others who might be facing a similar problem.

    My issue:

        <link rel="stylesheet" href="style.css">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
        <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
        <script type="text/javascript" src="slider.js"></script>
    

    My solution:

        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
        <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
        <link rel="stylesheet" href="style.css">
        <script type="text/javascript" src="slider.js"></script>
    
    0 讨论(0)
  • 2020-11-27 18:19

    Add your test.js file after the jQuery libraries. This way your test.js file can use the libraries.

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