javascript - Dynamically appending HTML elements using jQuery not working -


i need build button menu dynamically using javascript, cannot make work. i´m using bootstrap base style class.

here code:

<div class="well">     <button type="button" class="btn btn-primary btn-xs">button 1</button>     <button type="button" class="btn btn-primary btn-xs">button 2</button>     <button type="button" class="btn btn-primary btn-xs">button 3</button>     <small class="pull-right">right text</small> </div>   <div id="mymenu"> </div>  <script type="text/javascript">      $(document).ready(function () {          var upperwell = $("<div class='well clearfix'>");          $('mymenu').append(upperwell);          var createbutton = $("<button type='button' class='btn btn-primary btn-xs'>button1</button>");          var updatebutton = $("<button type='button' class='btn btn-primary btn-xs'>button 2</button>");          var exportbutton = $("<button type='button' class='btn btn-primary btn-xs'>button 3</button>");          $(upperwell).append(createbutton);         $(upperwell).append(updatebutton);         $(upperwell).append(exportbutton);      });  </script> 

the html code need build using javascript.

the given javascript code not working.

here fiddle shows code:

jsfiddle

help appreaciated. thanks.

you have forgotten # selector.

should this. $('#mymenu').append(upperwell);

updated: http://jsfiddle.net/p7ptl/2/


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -