Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript my basic jquery not working

  • This topic is empty.
Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #41469
    taragrg
    Member





    Hi friends click me to hide

    this is the code and its not working i am using the CDN instead of local jquery and why is it not working thanks

    #118202
    kevin11189
    Participant

    It’s working for me….

    http://jsfiddle.net/kevin11189/ZJPD4/

    #118204
    taragrg
    Member

    yea its working in your framework kevin11189 but its not working in my browser dont know why

    #118206
    kevin11189
    Participant

    Alright, this might be a little over my head, but I copied your text and made a little local site to text it out with 1.8.3.min.js and I noticed that there was some weird unseen characters in the source that isn’t in the code. I’m no pro when it comes to UTF stuff and line ending, but check your source in the browser and make sure there isn’t anything weird in your script that you don’t see in your editor.

    #118207
    kevin11189
    Participant

    But yeah, this works perfectly fine for me with 1.8.3.min.js





    Hello world!



    #118208
    kevin11189
    Participant

    Erg, the code block didn’t work, but yeah, let me know what your source shows. Can you link to the actual site?

    #118218
    JohnMotylJr
    Participant

    @taragrg : Remember that you need to close off your javascript resources with an ending script tag.

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
    #118226
    alfiebesin
    Participant

    @JohnMotylJr is right. You need to close your script tag there.
    Like this:

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>

    #118227
    alfiebesin
    Participant

    @JohnMotylJr is right. You need to close your script tag there.
    Like this:
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>

    #118239
    SgtLegend
    Member

    Just a couple of nitpicks, the below is the recommended way of writing jQuery.

    // This is the shorthand way of writing $(document).ready()
    $(function() {
    // Since jQuery 1.5 its now recommend you use the on() method
    $(‘p’).on(‘click’, function() {
    // Always use “this” as it referrers to the current element context not every p element
    $(this).hide();
    });
    });

    #118245
    taragrg
    Member

    yea i have ended the **script on the next line** ,I know the code is correct but why is this not working am not using IE i know it sucks

    #118301
    JohnMotylJr
    Participant

    @taragrg : For some reason i believe it may be some kind of syntax error. I suggest you either: A.) Upload your page to a server and post the link for us to see. B.) Copy ALL of your code and go to this website to convert characters. Once converted, come back to this forum, paste your new code, and wrap said new code inside of pre and code tags.

    The reason for this is so we can see exactly what you are doing because even though @SgtLegend have some great advice and @kevin11189 even gave you a working example, i believe you are missing something.

    Better yet, validate your html with the W3C tool.

    #118306
    joberndtsson
    Member

    Yes it’s a syntax error I believe Too.

    John B

    #118307
    joberndtsson
    Member

    #118377
    taragrg
    Member

    Thanks to all its working fine Thanks thanks thansk :) it was just a syntax error thanks JohnMotylJr

Viewing 15 posts - 1 through 15 (of 15 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.