1

I'm writing some jQuery to modify options in a form. I noticed that when I use .append() for multiple elements at once it will work like this:

$("#item").append("<option>Item 1</option><option>Item 2</option><option>Item3</option>");

But if I try to clean it up so it's not such a long unreadable line like this:

$("#item").append("<option>Item 1</option>
                   <option>Item 2</option>
                   <option>Item3</option>");

It won't work? Why? And is there any workaround for this?

Matt Corby
  • 11,984
  • 3
  • 12
  • 19

1 Answers1

0

You can do it that way.

$("#item").append("<option>Item 1</option>"+
                   "<option>Item 2</option>"+
                   "<option>Item3</option>");
Devsullo
  • 864
  • 1
  • 9
  • 14