What do you need to access outside the $(function(){})?
For the function you can do something like this:
var showtime;
$(function(){
//...
showtime = function() {
//...
};
})
// You can now do this
showtime();
Is that what you're looking for?
Karl Rudd
On Thu, Feb 14, 2008 at 10:20
thx karl, im still learning jquery is a great thing, sometimes is miss
the logic about it.
and its work perfect, now the cpu is 5 to 11%, and i notice i must
define the function showtime inside the $(function(){} because i lose
the vars in other way, but how i can make it work from outside?
Part of the problem may be that the elements are being searched every
time the function is called.
$('.year').text(anio);
$('.day').text(dia);
$('.month').text(mes);
$('.week').text(week);
$('span.h').text(String(hours));
$('span.minute').text(String(minutes));
$('span.seconds
Rather than call the function recursively, you might want to use setInterval
rather than setTimeout, which is what I think you are trying to
achieve...that is, run the function once per second.
I think if you run the function recursively without an "exit strategy" you
get a circular behavior
Where's the "show_clock()" function? Or was that a typo?
Otherwise, I don't see anything glaringly wrong with the code (just a
quick glance though...)
Shawn
Sebastián V. Würtz wrote:
can this code kill a cpu?
$(function() {
show_clock();
});
function showtime() {
var meses = new
5 matches
Mail list logo