javascript - select2.js - How to align two items inside option element -
i want align 2 items inside <option>
element using select2.js plugin.
for example, here:
<select id="myexample" class="pull-left"> <option value="1" class="pull-left"><span class="pull-left">item </span><span class="pull-right">company a</span></option> </select>
i want item aligned on left , company aligned on right.
how can achieve that? tried using css doesn't seem working.
use delimiter string, on example used "~" , split after select2 escaped markup :
$("select").select2({ escapemarkup : function(text){ text = text.split("~"); return '<span class="pull-left">'+text[0]+'</span><span class="pull-right">'+text[1]+'</span>'; } });
while on select, should use :
<select id="myexample" class="pull-left"> <option value="1" class="pull-left"> item a~company </option> </select>
here working fiddle : http://jsfiddle.net/wphqwvlf/55/
Comments
Post a Comment