javascript - Dynamically created bootstrap buttons lose space padding -
i have bootstrap button bar using well class repeated twice in code: 1 created using html code , using dynamic javascript.
when use html, bootstrap works fine.
whan use javascript create it, buttons lose padding.
the result expect same in both code.
why dynamic created 1 not respect original horizontal spacing html created 1 has ?
does can me that.
original 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 jsfiddle here:
thanks help.
the static buttons have whitespace between them, appended buttons don't. can add space between each button...
$(upperwell).append(createbutton).append(" "); $(upperwell).append(updatebutton).append(" "); $(upperwell).append(exportbutton); or can add space after each button after they're appended...
$(upperwell).append(createbutton); $(upperwell).append(updatebutton); $(upperwell).append(exportbutton); $("#mymenu button").after(" ");
Comments
Post a Comment