0

I am using jsclock jquery library to display realtime clock on my website. But i cant seem to use the given function to pass the value to the element

I tried using this method

$("input[id='mytime']") = jsclock();

The example code for this jquery library was

$('#mytime').jsclock();

This was working

<div id="mytime"></div>

But how to do it for a input element?

<div class="form-group">
    <label for="mytime"></label>
    <input type="text" class="form-control" id="mytime" value="" disabled>
</div>

My javascript file

$(document).ready(function(){
    // $('#mytime').jsclock();

    $("input[id='mytime']") = jsclock();
});

It should show current clocktime

KIRPAL SINGH
  • 185
  • 2
  • 17
  • Their documentation says: "_Usage: To replace the innerHTML of the selected elements with a clock ..._" Input element is an empty element and can't have HTML, hence it's not possible to use an input element as a parent of jsclock. – Teemu Dec 22 '18 at 10:44
  • @Teemu So is there any alternative? – KIRPAL SINGH Dec 22 '18 at 10:53
  • You could emulate an input with e.g. a pre element, or just style a div to look like an input element. If you need to pass the time to your server in a form, you can use input type of hidden, and set the value in an submit event handler. – Teemu Dec 22 '18 at 11:07

0 Answers0