piraids,
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script>
$(function() {
jQuery.fn.digitalWatch = function() {
function formatTime(num)
{
return ("0" + num).substr(-2)
}
this.each(function(i, el) {
var el = $(el),
init = function() {
var date = new Date,
hours = date.getHours(),
minutes = date.getMinutes(),
seconds = date.getSeconds();
hours = formatTime(hours);
minutes = formatTime(minutes);
seconds = formatTime(seconds);
el.html(hours + ":" + minutes + ":" + seconds);
setTimeout(init, 1000)
};
init()
});
return this
};
$(".clock").digitalWatch().css({
color: "red"
})
});
</script>
</head>
<body>
<div class="clock"></div> <div class="clock"></div>
</body>
</html>