dimanche 12 avril 2020

How to get the span text from a checkbox using Javascript?

Suppose I have the following bit of code:

  <p>
    <label>
      <input name="milk" type="checkbox">
      <span>Milk</span>
    </label>
  </p>

How can I use javascript to obtain the text between the span tags? The result should be Milk if logged onto the console. Thank you!




Aucun commentaire:

Enregistrer un commentaire