Well, it appears you are binding an event to something that doesn't exist. Here's what's happening with your code:
== Page loads -> Bind click to checkbox (no checkbox exists so nothing happens) -> Bind submit to form to create a checkbox == User action -> User clicks submit, a checkbox is created. -> User clicks on checkbox, nothing happens -- Done What you want to do is: == Page loads -> Page loads -> Bind submit to checkbox to create a checkbox AND bind a click event to the checkbox == User action -> User clicks submit, a checkbox is created and a click event is bind to the checkbox -> User clicks on checkbox, 'test' is alerted On Mar 20, 11:00 am, "omertacod...@gmail.com" <omertacod...@gmail.com> wrote: > hi all, > > I have a problem, when the checkbox is clicked there is no reaction. > here is the code: > > index.html > > <html> > <head> > <title>test</title> > <script type="text/javascript" src="jquery.js"></script> > <script type="text/javascript" src="darkTodo.js"></script> > <style type="text/css"> > #messagewindow { > height: 250px; > border: 1px solid; > padding: 5px; > overflow: auto; > } > #wrapper { > margin: auto; > width: 438px; > } > </style> > </head> > <body> > <div id="wrapper"> > > <form id="chatform"> > <p>Wat ?</p><p><input type="text" id="author" /></p> > <p>Todo</p><p><input type="text" id="msg" size="50"/></p> > <input type="submit" value="ok" /><br /> > </form> > > <div id="messagewindow"> > </div> > </body> > </html> > > and the javascript : > > $(document).ready(function(){ > > $(':checkbox').click(function(){ > alert("test"); > > }); > > $("form#chatform").submit(function(){ > $test = '<input name="test" type="checkbox" value="1">'; > > $("#messagewindow").prepend($test+"<b>"+$("#msg").val()+"</b><br />"); > > return false; > }); > > }); > >