Fez Vrasta
Fez Vrasta

Reputation: 14815

Change value of input[type=time]?

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?

Upvotes: 6

Views: 23375

Answers (2)

MackieeE
MackieeE

Reputation: 11862

As you may know, you must provide a RFC3339 Standardised time format. Explained in the Internet Date/Time Formats Document Spec. 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.

Upvotes: 8

Marcelo Agim&#243;vel
Marcelo Agim&#243;vel

Reputation: 1719

you can try this:

$("#someid").val("10:15");

It work's fine here.

Upvotes: 1

Related Questions