first please excuse my english, I'm not a native speaker. I have a really weird problem. I have these two multiple select boxes:
<select id="leftEntities" class="width390px" multiple="multiple" size="8">
<option value="1">Option A</option>
<option value="2">Option B</option>
</select>
<select id="rightEntities" class="width390px" multiple="multiple" size="8">
<option value="1">Option C</option>
<option value="2">Option D</option>
</select>
and this button which should perform an invert of the selected options.
<button id="invert" class="btn btn-primary glyphicon glyphicon-transfer"></button>
This is the JQuery Code:
$(document).ready(function(){
$('#invert').click(function() {
SWAPLIST.invert($(this).parent().find('select'));
});
});
var SWAPLIST = {};
SWAPLIST.invert = function(list) {
$(list)
.children()
.prop('selected', function(i, selected) {
return !selected;
});
}
The problem is that this works like it should work, when there's no div container around the button, but if I put one around it, it does not work anymore.
In other words, this is what not works:
<div class="sometestclass">
<button id="invert" class="btn btn-primary glyphicon glyphicon-transfer"></button>
</div>