Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my quest to rid my project of jquery this is the last bit I need help with
This works - datetime picker pops up as expected on every input of type datetime
$('input[type=datetime]').datetimepicker({
            dateFormat: "dd-M-yy",
            changeMonth: true,
            changeYear: true,
            inline: false,
            step: 15,
            weeks: false,
            defaultTime: '09:00'
        });


This doesn't
document.querySelectorAll('input[type=datetime]').datetimepicker({
        dateFormat: "dd-M-yy",
        changeMonth: true,
        changeYear: true,
        inline: false,
        step: 15,
        weeks: false,
        defaultTime: '09:00'
    });


Any ideas ?

What I have tried:

$('input[type=datetime]').datetimepicker({
            dateFormat: "dd-M-yy",
            changeMonth: true,
            changeYear: true,
            inline: false,
            step: 15,
            weeks: false,
            defaultTime: '09:00'
        });


This doesn't
document.querySelectorAll('input[type=datetime]').datetimepicker({
        dateFormat: "dd-M-yy",
        changeMonth: true,
        changeYear: true,
        inline: false,
        step: 15,
        weeks: false,
        defaultTime: '09:00'
    });
Posted
Updated 9-Sep-21 6:34am
Comments
Member 15329613 9-Sep-21 12:55pm    
Jquery is lightweight and easy to use. Any reason you are trying to get rid of it?

1 solution

The datetime picker you're using relies on jQuery. You can't use it without jQuery.

If you want to get rid of jQuery, you'll need to find an alternative plugin - for example:
Lightpick - Javascript date range picker - lightweight, no jQuery[^]

To be honest, the built-in browser UI for <input type="date"> and <input type="time"> is usually good enough these days. But the <input type="datetime"> has been deprecated, and isn't supported in any browser.
 
Share this answer
 
v2
Comments
pkfox 9-Sep-21 13:59pm    
Ok thanks Richard I'm only using this in a personal project - I'm sure you realise I'm not a Web dev :-)
pkfox 10-Sep-21 3:48am    
HI Richard, I tried the type=date and it does pop up a date picker but type=time only gives me two input areas no pop up picker - is this expected ?
Richard Deeming 10-Sep-21 3:51am    
That's fairly standard for desktop browsers, with the exception of Edge:
<input type="time"> - HTML: HyperText Markup Language | MDN[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900