Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change value of input[type=time]?

Tags:

html

jquery

I'm trying to change the value of an input with type time but I can't find a solution.

This is my attempt:

$("input").val("10.15");

Fiddle: http://jsfiddle.net/bUYC6/

How can I do?

like image 257
Fez Vrasta Avatar asked Apr 08 '14 15:04

Fez Vrasta


1 Answers

As you may know, you must provide a RFC3339 Standardised time format, better explained the in Internet Date/Time Format So a clean input would be:

$("input").val( "18:01:07" );

###Fiddle: http://jsfiddle.net/2btUd/

Although I believe you're trying to input a secfrac (A fraction of a second..) as explained in the above link, which you could apply:

<input type="time" value="" step="0.10" />
<script>
    $("input").val( "00:00:00.10" );
</script>

###Fiddle: http://jsfiddle.net/7eh93/

Which understandably isn't a clean method, but I don't think <input type="time" /> is best worked with time-fractions.

like image 197
MackieeE Avatar answered Sep 21 '22 05:09

MackieeE