Skip to content

Instantly share code, notes, and snippets.

@rockkhuya
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rockkhuya/8816013 to your computer and use it in GitHub Desktop.
Save rockkhuya/8816013 to your computer and use it in GitHub Desktop.
Use push to write HTML code in Javascript
var new_element = [];
new_element.push(
'<ul class="inline nested-fields" shp-role="dynamic_field_need_things" id="', num, '">',
'<li>',
'<input class="input-mini" id="', num, '" name="need_things" shp-role="dynamic_field_need_things" type="text" />',
'</li>\n',
'<li><a id="', num, '" shp-role="delete_field_need_things">×</a> </li>',
'</ul>'
);
new_element.join('');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment