jonthornton/jquery-timepicker

$('#spanExample').val() does not work

Silex opened this issue · 6 comments

Silex commented

Hello,

We cannot retrieve the value of non-input elements.

On https://www.jonthornton.com/jquery-timepicker/, the only way I found out that works is $('#spanExample').data('uiTimepickerValue').

What does this return?
$('#spanExample').html()

Silex commented

It returns "".

You can try it yourself at https://www.jonthornton.com/jquery-timepicker/ scroll to "Non-input Example" pick a time then fire up the dev console and test $('#spanExample').html() or $('#spanExample').val() and see they don't work while $('#spanExample').data('uiTimepickerValue') does.

The time picker does not put any time into the 'red-square'. Is it supposed to hide the selected time from the end user?

Silex commented

I think so?

The documentation for this feature isn't great, sorry for the confusion.

If you attach timepicker to a non-input element, $.val() isn't going to work. The most reliable way to get the time value in that situation will be timpicker's getTime or getSecondsFromMidnight methods.

Silex commented

Thanks 👍