javascript - JQuery .append of a </select> tag ignored -


this question has answer here:

i have following html:

<div id='show-label'>   <select id="comboboxshowlabel">     <option value="">hide or show labels?</option>     <option value="show labels">show label</option>      <option value="hide labels">hide label</option>   </select> </div> 

i want add the <select></select> parent div @ runtime, ala:

     <div id='show-label'>      </div>      $("#show-label").html("<select id='comboboxshowlabel'>")         .append("<option value=''>hide or show labels?</option>")         .append("<option value='show labels'>show label</option>")         .append("<option value='hide labels'>hide label</option>")         .append("</select>");        

for resons unknown me, closing tag isn't getting injected page.

i've tried code above this:

.append("<option value='hide labels'>hide label</option></select>") 

is there sort requirement around "batching" these elements single .append? i'm wondering if approach doesn't seem well-formed when it's loading dom, it's ignored...

thanks!

try this:

$("#show-label").append(function() {     return $("<select id='comboboxshowlabel'>")         .append("<option value=''>hide or show labels?</option>")         .append("<option value='show labels'>show label</option>")         .append("<option value='hide labels'>hide label</option>"); }); 

Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -