Show function with IF/Else Statement
Show's one thing if value is empty or "Null", and otherwise shows something else
HTML
<div id=row1 style="font-weight:bold">Row 1 - Nothing selected</div>
<div id=row2 style="font-weight:bold; display:none;">Row 2 - Something selected</div>
<div id=row3 style="font-weight:bold; display:none;">Row 3 - Something selected</div>
<div id=row4 style="font-weight:bold; display:none;">Row 4 - Something selected</div>
<select name=item1 class="field" multiple>
<option value="Null">Select</option>
<option value=1>Option 1</option>
<option value=2>Option 2</option>
<option value=3>Option 3</option>
</select>
JavaScript
$(function () {
$(".field").change(function () {
var selectionArray = $(this).val();
$("#row1, #row2").hide();
console.log(selectionArray);
if (selectionArray === null || (selectionArray.length===1 && !$.inArray("Null", selectionArray))) {
$("#row1").show();
} else {
$("#row2").show()
};
});
});