0

Code written by me based on previous suggestions as follows .

Any help to efficinetly use jquery in order to make this code work . Thanks in advance

$(document).ready(function()  
     {
              self.setInterval("clock()",1000);  
              $("button").click(function()  
              {  
                     clock;  
              });  
              function clock()  
              {
                   clock();  
                   time=new Date();  
                   var s = "<p>" + time + "</p>";  
                   $(s).appendTo("div");  
              }  
     });  

<button > Click Me button  </div>
<div id="someid"></div>
0

1 Answer 1

1

$("button").click(function() should be either $("#button").click(function() or $(".button").click(function() depending on whether you are using the id or the class name.

if you are attaching to all buttons then $("input:button").click(function() will work I think.

Also what is $(s).appendTo("div"); meant to be doing?

Need more info on what is not working and what you want to achieve.

edit

$(s).appendTo("div");

should be $('#someid').append(s); I think or $(s).appendTo('#someid');

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.