Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Nov 2016
    Posts
    16
    Thanks
    3
    Thanked 0 Times in 0 Posts

    jquery link in html

    Hi,

    what code should i write in the html if i want to link the jquery file im working on?
    i'm still not working in a server, so i think ajax doesnt work in here.
    Is it possible to write jquery in a program as notepad++? (i'm using 'brackets')

    thanks

  2. #2
    Administrator VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    10,781
    Thanks
    6
    Thanked 1,285 Times in 1,255 Posts
    You can write JavaScript (which jQuery is) in any plain text editor you like. You reference an external JS file in HTML with a script element:

    Code:
    <script src="path/to/file.js" type="text/javascript"></script>
    And you can still do simple asynchronous requests, even without a server.

  3. #3
    New Coder
    Join Date
    Nov 2016
    Posts
    16
    Thanks
    3
    Thanked 0 Times in 0 Posts
    thank you, but for some reason im still doing something wrong.
    this is my link:

    <script type="text/javascript" src="Jquery.js"></script>

    the src is the file name.

    and this is my jquery file

    $(document).ready(function() {


    });


    the jquery still doesnt effect the html file..

  4. #4
    Administrator VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    10,781
    Thanks
    6
    Thanked 1,285 Times in 1,255 Posts
    1. Is the JS file in the same directory as the HTML file? According to the file path you provided the browser is looking there.
    2. Have you actually included the jQuery core library?


    Every fairly modern browser has a built-in developer console. Open that and look what messages it gives you (if any).

  5. #5
    Senior Coder deathshadow's Avatar
    Join Date
    Feb 2016
    Location
    Keene, NH
    Posts
    2,238
    Thanks
    2
    Thanked 327 Times in 317 Posts
    1) this is 2016, you don't need to say type="text/javascript" anymore. (not that you ever REALLY did)

    2) src="Jquery.js" -- are you 100% sure that's correct since filenames on web hosting are CASE SENSITIVE? That leading upper-case J could be biting you.

    USUALLY the jquery link would look something more like this:

    <script src="jquery-3.1.1.min.js"></script>

    Assuming of course that you HAVE the jquery file with that name in the right place.

    Also be VERY sure you have that <script> BEFORE your own scripting that tries to call the mouth-breathing dumbass code-bloat rubbish that is jQuery.

    NOT that there's any legitimate reason to use that fat bloated steaming pile of manure that only teaches you sloppy outdated outmoded coding habits, pisses on accessibility, and guts the usefulness of the majority of sites it is slopped into any-old-way -- but you want to tell large swaths of visitors to your sites to sod off, that's your call.
    I would rather have questions that can't be answered, than answers that can't be questioned.
    http://www.cutcodedown.com

  6. #6
    Regular Coder
    Join Date
    Sep 2010
    Location
    U S of A
    Posts
    220
    Thanks
    4
    Thanked 41 Times in 41 Posts
    Quote Originally Posted by idowieder View Post
    thank you, but for some reason im still doing something wrong.
    this is my link:

    <script type="text/javascript" src="Jquery.js"></script>

    the src is the file name.

    and this is my jquery file

    $(document).ready(function() {


    });


    the jquery still doesnt effect the html file..
    I read this message as

    the file named Jquery.js contains ...
    $(document).ready(function() {


    });


    Try this the ask more questions ...


    Code:
    <!DOCTYPE html>
    <html>
    <head>  
    <script  src="https://code.jquery.com/jquery-3.1.1.js"></script>
    <script>$(document).ready(function() {
    alert('READY')
    });
    </script>
     </head>
    <body>
    </body>
    </html>
    Last edited by Shaka Zorba; 12-21-2016 at 12:18 PM.


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •