onclick error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pradeepjain
    Contributor
    • Jul 2007
    • 563

    onclick error

    Code:
    <input type='button' id='rate-it' value='rates-it' >
    
    <script type='text/javascript'>
        $("#rate-it").click(function () { 
    alert('yes');
    }); 
        </script>
    i am trying to get an onclick feature ,but onlick is not working properly .

    when i check the error console it says
    $("#rate-it") is null .. whts the problem?
  • RamananKalirajan
    Contributor
    • Mar 2008
    • 608

    #2
    Are you using any framework like (jquery, prototype, extjs) in this code?

    Thanks and Regards
    Ramanan Kalirajan

    Comment

    • pradeepjain
      Contributor
      • Jul 2007
      • 563

      #3
      yeah using a lightbox prototype in the page.

      Comment

      • RamananKalirajan
        Contributor
        • Mar 2008
        • 608

        #4
        Is it necessary to give the id like $("#rate-it")?

        Thanks and Regards
        Ramanan Kalirajan

        Comment

        • pradeepjain
          Contributor
          • Jul 2007
          • 563

          #5
          yeah id representation is done through "#" only rite !!

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            You probably need to wrap that code in some onload event handler, so that you're referencing the element after it's available.

            Comment

            Working...