OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

click listener of an html option element

  • Thread starter Thread starter Vickÿ code
  • Start date Start date
V

Vickÿ code

Guest
I am trying to assign an click eventlistener to a html option element, I want to display the time picker in a task management project using HTML,CSS and vanilla JAVA-SCRIPT by selecting a choose-date option,How can i resolve this issue using only simple Java-Script?

Here my code:


Code:
const chooseDate = document.getElementById("choose-date");
chooseDate.addEventListener("click", () => {
  document.getElementById("date").classList.remove("hidden");
});

Code:
body {
  background-color: rgb(143, 134, 134);
}

input,
select {
  position: absolute;
  left: 50%;
  bottom: 50%;
  height: 40px;
  font-size: 20px;
  border-radius: 20px;
}

input {
  bottom: 45%;
  display: none;
}

Code:
<select name="selection" id="my-selection">
  <option value="today">today</option>
  <option value="tomorrow">tomorrow</option>
  <option value="choose-date">choose-date</option>
</select>
<input type="datetime-local" name="" id="" />

<p>I am trying to assign an click eventlistener to a html option element, I want to display the time picker in a task management project using HTML,CSS and vanilla JAVA-SCRIPT by selecting a choose-date option,How can i resolve this issue using only simple Java-Script?</p>
<p>Here my code:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>const chooseDate = document.getElementById("choose-date");
chooseDate.addEventListener("click", () => {
document.getElementById("date").classList.remove("hidden");
});</code></pre>
<pre class="snippet-code-css lang-css prettyprint-override"><code>body {
background-color: rgb(143, 134, 134);
}

input,
select {
position: absolute;
left: 50%;
bottom: 50%;
height: 40px;
font-size: 20px;
border-radius: 20px;
}

input {
bottom: 45%;
display: none;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><select name="selection" id="my-selection">
<option value="today">today</option>
<option value="tomorrow">tomorrow</option>
<option value="choose-date">choose-date</option>
</select>
<input type="datetime-local" name="" id="" /></code></pre>
</div>
</div>
</p>
 
Top