Reputation: 1131
Hi all i am look for way to fire and event event time the values changes.
So i have got a live clock running in a div called.
<span id="LiveClockIE">The time is: 9:37:24 AM</span>
What i want to do is fire a event everytime the clock changes ie every sec??
tried
$("#LiveClockIE").val().change(function () {
console.log('change event');
})
.change();
And
$("#LiveClockIE").change(function () {
console.log('change event');
})
.change();
Help please
Upvotes: 0
Views: 814
Reputation: 707258
The change event you have in your code example only fires on some types of fields and only when the field loses focus. It does not ever fire when the content is changed programmatically.
If you actually wanted to know every time some piece of JS code was updating the LiveClockIE span, then you'd probably have to hook into or modify whatever code was doing the updating of the span and have it call your callback too every time it changes the clock time.
FYI, this will call yourFunc once a second (though not exactly at the same moment that the clock is updated, but just as frequently).
setInterval(yourFunc, 1000);
Upvotes: 3