How to make jquery works after I copied some code

Discussion in 'jQuery' started by kentzhu, Oct 29, 2010.

  1. #1
    I'm new for jquery.

    How to make jquery works after I copied some code to my web editor?
    Because it always shows me an error message after I run it.

    Thanks

    Kent
     
    kentzhu, Oct 29, 2010 IP
  2. Cash Nebula

    Cash Nebula Peon

    Messages:
    1,197
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What was the error message? Have you included the Jquery library?
    <script type="text/javascript" src="jquery.js"></script>
     
    Last edited: Nov 1, 2010
    Cash Nebula, Nov 1, 2010 IP
  3. kentzhu

    kentzhu Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3

    Hello,
    Thanks for your mail. Here is the message below: How to make code works without this error?

    Webpage Error
    Do you want to debug this webpage?
    This webpage contains errors that might prevent it from displaying or working correctly. If you are not testing this webpage,click No.

    Line:16
    Error: Object doesn't support this property or method
     
    kentzhu, Nov 1, 2010 IP
  4. Cash Nebula

    Cash Nebula Peon

    Messages:
    1,197
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Unfortunately, the error message is too vague. We need to see the source code too, or just the section containing line 16.
     
    Cash Nebula, Nov 1, 2010 IP
  5. kentzhu

    kentzhu Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Here is the source code below, it shows error after I run this code.
    <html>
    <head>
    <script src="prototype.js"></script>
    <script src="jquery-1.4.3.js" type="text/javascript"></script>
    <script>
    jQuery.noConflict();

    // Use jQuery via jQuery(...)
    jQuery(document).ready(function(){
    jQuery("div").hide();
    });

    // Use Prototype with $(...), etc.
    $('someid').hide();
    </script>
    </head>
    <body></body>
    </html>

    Thanks for help.
    K
     
    kentzhu, Nov 2, 2010 IP
  6. GNi33

    GNi33 Peon

    Messages:
    16
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    it would be interesting what you try to achieve with your code?
    the code you copied would simply hide all the divs on your page, so right now it wouldn't do anything really anyhow...

    I don't know why you are using prototype too in there.
    Try to put out the prototype code at first, get some divs into the body and see if the error is still there.
    Unfortunately I don't know prototype, so I can't say if there's a problem with that one code line...
     
    GNi33, Nov 2, 2010 IP
  7. kentzhu

    kentzhu Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7

    I tried this code and had same problem and error message.
    <html>
    <head>
    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
    $("p").click(function(){
    $(this).hide();
    });
    });
    </script>
    </head>
    <body>
    <p>If you click on me, I will disappear.</p>
    <p>Click me away!</p>
    <p>Click me too!</p>
    </body>
    </html>
     
    kentzhu, Nov 2, 2010 IP
  8. GNi33

    GNi33 Peon

    Messages:
    16
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Alright, this is weird.

    What version of jQuery are you using? Try downloading the latest one from the jquery-website.
     
    GNi33, Nov 2, 2010 IP
  9. Cash Nebula

    Cash Nebula Peon

    Messages:
    1,197
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #9
    What browsers are showing the error? Is it a PHP or HTML file?

    That second script works fine, so maybe the errors are from a cached version of the first script.
     
    Cash Nebula, Nov 2, 2010 IP