How can I put my label and my select on the same line in case of this code?
<div class="form-group">
<div>
<label>Filtrar por Categoria:</label>
<div id="select-categories"></div>
</div>
</div>
Javascript:
$("#select-categories").each( function ( i ) {
var select = $('<select class="form-control"><option value=""></option></select>')
.appendTo( $(this).empty() )
.on( 'change', function () {
table.column( [2] )
.search( $(this).val() )
.draw();
} );
table.column([2]).data().unique().sort().each( function ( d, j ) {
select.append( '<option value="'+d+'">'+d+'</option>' )
} );
} );
You may set your display to inline-block as in the snippet below. Another good way is to use the Boostrap's column or grid systems . By the way, your JavaScript has references to html elements that you never defined. Hence, I did not use it. In addition, your label was blank to I added some text for testing.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="form-group"> <div> <label style="display: inline-block;">Filtrar por Categoria:</label> <div style="display: inline-block;" id="select-categories">Label</div> </div> </div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.