jeudi 19 août 2021

JavaScript conditional function with counter functionality | on switch [duplicate]

Can you guys please help I want to make this function that when someone selects an option on the list it shows counter other-vise not? this is just a example

<option value="one"> 1 </option>
<option value="two"> 2 </option>
</select>


If(value = "one" )

{

  show counter/ function
  //this is the function
  [
    var clicks = 0;
        function onClick() {
          clicks += 1;
          document.getElementById("clicks").innerHTML = clicks; 
          };
  ]

}

else

{

  display none the counter

}

Aucun commentaire:

Enregistrer un commentaire