Click here to Skip to main content
15,891,248 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi, I want to show "hello" message in button click event which is calling by Ajax. But, this is not working.

HTML
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>

JavaScript
script type="text/javascript">
    $('#readfile').click(function(){alert("hello");});
 </script>

HTML
 </head>
 <body>
       
        <button id="readfile" name="readfile">show</button>
    </body>
</html>


Please tell me why this is not working ? Is there any problem in my code ?
Posted
Comments
ZurdoDev 8-Apr-13 11:53am    
Do you have the < before script?
Sergey Alexandrovich Kryukov 8-Apr-13 12:20pm    
:-) !!!
UL UL ALBAB 8-Apr-13 14:54pm    
yes I have.
ZurdoDev 8-Apr-13 15:03pm    
Did putting it into the document.ready work?
UL UL ALBAB 8-Apr-13 14:57pm    
yes I have.

1 solution

Wrap the .click assignment in the document ready function.
JavaScript
$(document).ready(function() { $('#readfile').click(function(){ alert('hello'); }); });
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900