I am currently utilizing the select2 plugin for my select dropdowns on a webpage. I have multiple select dropdown boxes and I need to implement a floating label specifically for the selected dropdown.
Despite my efforts and searches, I have not been able to find the desired results I was hoping for.
Below is the code that I have been working with:
HTML
<div class="container">
<div class="row">
<div class="col-md-6 col-lg-6 col-sm-6">
<label class="hor-menu visible-xs visible-xs control-label col-sm-1"></label>
<div class="form-group form-md-line-input form-md-floating-label" style="margin-top: 13px;">
<select name="cboNGrp" id="cboNGrp" class="form-control select2me input-xlarge" data-live-search="true" data-size="8"></select>
<label class="form_control_1 head_ctrl_label" style="padding-top: 2px;">Type</label>
</div>
</div>
<div class="col-md-6 col-lg-6 col-sm-6">
<div class="form-group form-md-line-input head_ctrl">
<label class="hor-menu visible-xs visible-xs control-label col-sm-1"></label>
<select name="cboEmrGrp" id="cboEmrGrp" class="select2me form-control input-xlarge"></select>
<label class="form_control_1 head_ctrl_label">E / M</label>
</div>
</div>
</div>
</div>
JS
$('.select2me').click(function(e){
if($(this).find('select2-dropdown-open')) {
$('label.head_ctrl_label').css('margin-top', '-25px');
}
e.preventDefault();
});
Image of user interaction with Dropdown selection
Image displaying bug where floating label applies to all dropdowns instead of just the selected one