-1

Need some help, trying to make the "Choose your Installments plant" text as selected so is the default text that my customers will see before choosing from a dropdown the number of installments.

html = "<p><select class=\'installments-box\'><option value=\'-1\'>Choose your Installments plan</option>"; 

2 Answers2

1

Use the selected attribute on the <option> that you want to be selected by default.

Charles Stover
  • 1,132
  • 6
  • 13
0

It's not necessary to set the selected attribute to make a select tag display the first option by default.

Simply omit the value attribute from the first option, or set it to an empty string and the select will display the first option as selected.

Pen: https://codepen.io/alsoicode/pen/jpPxgx

Brandon Taylor
  • 33,823
  • 15
  • 104
  • 144