0

I have a successfully working input field for a form that looks like this

HTML:

<li><input type="text" name="1" placeholder="answer #1"></li>

and I want to make it so that when a button is clicked a new input field is created mimicing the first but with incrementing numbers. The following code successfully does that, right up until the "placeholder" field in which it only shows the first word

JAVASCRIPT

$("#fieldList").append("<li><input type=text name=" + variable + " placeholder=answer #" + variable + "></li>");

I've tried various combinations of using " alongside standard " marks, but none of them are getting the formatting as the straight HTML version above shows. I feel like this is a basic syntactical error but I can't figure out what I'm missing.

Josh McGee
  • 443
  • 6
  • 16
  • ah, I hadn't thought of using single quotes! thankyou! you've got a typo in your answer by the way, it doesn't work with a single quote after the # – Josh McGee Nov 28 '16 at 14:20
  • Ah right, I added 1 too many single-quotes. – Sunny Patel Nov 28 '16 at 14:23