0

HTML:

<td>
    <select name="student">
        <option value="">--Select one --</option>
    </select>
</td>

Now to this existing element, I need to add option tags in JavaScript.

I tried this way in JS but it is not working

document.getElementById("student").append("<option value="1">Pooja</option>);
cdlane
  • 40,441
  • 5
  • 32
  • 81
  • 1
    `append` is not a method of `DOM element` Use `appendChild()`..Also note, `appendChild` should have `option element` as argument – Rayon Mar 30 '16 at 05:51
  • `document.getElementById("student").appendChild(new Option(text, value))`. See [*MDN: Option()*](https://developer.mozilla.org/en-US/docs/Web/API/HTMLOptionElement/Option). – RobG Mar 30 '16 at 06:11

0 Answers0