开发者

using javascript with help of jquery

开发者 https://www.devze.com 2023-01-02 22:11 出处:网络
Code written by me based on previous suggesti开发者_StackOverflow中文版ons as follows . Any help to efficinetly use jquery in order to make this code work .

Code written by me based on previous suggesti开发者_StackOverflow中文版ons 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>


$("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');

0

精彩评论

暂无评论...
验证码 换一张
取 消