vendredi 29 mai 2020

Automatically tick checkbox when clicking on another form input field

I'm trying to have a checkbox next to a form text-input field. The checkbox can be ticked on/off normally, however when clicking on the text-input field, the checkbox should be automatically ticked as well.

I tried this with putting the text-input inside the label for the checkbox, but it doesn't work. It works fine when I use normal text instead of the input-field:

<input type="checkbox" id="box">
<label for="box">
  <input type="text">
</label>

How can I achieve this with HTML/JS? I'm working in the context of a VueJS plugin.




Aucun commentaire:

Enregistrer un commentaire