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');
精彩评论