[Vuejs]-How do I close the picker for type="datetime-local"

1👍

Use the blur method to close the picker when any time/date is selected.

Here is the demo-

<html>
  <div id="app">
    <input type="datetime-local" id="td" name="td" @input="close()" />
  </div>
  <!-- Don't forget to include Vue from CDN! -->
  <script src="https://unpkg.com/vue@2"></script>
  <script>
    new Vue({
      el: '#app', //Tells Vue to render in HTML element with id "app"
      methods: {
        close() {
          let el = document.getElementById("td");
          if (el) {
            el.blur();
          }
        },
      }
    });
  </script>
</html>

Leave a comment