Is there a JavaScript method to make a html date input display the datepicker

Is there a JavaScript method to make a html date

Summary

This text will be hidden

input display the datepicke

Hey! the question seems a bit too vague, can you tell us more about what you’re trying to accomplish so its easier for us to help you ! :smile:

i just want to show the date selection after the button is click

ahhh so there’s multiple ways you can accomplish it.the easiest would be to use the “class switch” method.

Basically, on each button click, you can check if a class exists on the button and if it does, you can remove it and if it doesn’t you can add it.

so in the CSS i can have =

.hidden{
    display: none;
}

and in javascript i can toggle this class whenever a user clicks on the button and to accomplish that i can add an event listener to that particular button.


myButton.addEventListener("click", ()=>{
    myInput.classList.toggle("hidden")
})

Hope this helps! :smile:

1 Like

It looks like there’s a showPicker() method, but it’s relatively new so it may not be supported in your browser.

1 Like

thank you sir, this is also helpful for me I want also to toggle some element

thank you sir this is the solution I need

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.