Why I dont see my date if I change the value ?
<button class="btn">Button</button>
<input type="date" value="" class="dt" />
<script>
button.addEventListener('click', () => {
const dateS = document.querySelector('.dt');
dateS.value = '2022-02-02';
});
</script>
it shows me this:
tt.mm.jjjj
the value is changed but not displayed
You need to define your button element before using it. const button = document.querySelector('.btn');
check the code below.
<button class="btn">Button</button>
<input type="date" value="" class="dt" />
<script>
const button = document.querySelector('.btn');
button.addEventListener('click', () => {
const dateS = document.querySelector('.dt');
dateS.value = '2022-02-02';
});
</script>