Camillia
asked on
== and === why is it working like this?
I don't understand why I needed to use == instead of === in code below. When I use ===, code doesn't go down the correct if else block
This works but if I change it === ... only else block gets executed
<select class="form-control valid" id="ddlRoles" name="ddlRoles" aria-invalid="false">
<option value="1">CSI STL - User</option>
<option value="2">Ferguson - User</option>
<option value="3">CSI Demo - User</option>
<option value="4">Customer Admin - US/Canada</option>
<option value="5">Customer Manager - US/Canada</option>
<option value="6">Customer User - US/Canada</option>
<option value="7">CSI AE - US/Canada</option>
</select>
This works but if I change it === ... only else block gets executed
$('#ddlRoles').change(function() {
console.log($('#ddlRoles').val());
if ($('#ddlRoles').val() == 3) {
$("#camilladefault").hide();
$("#camilladivtest").show();
$("#camilladivtestFer").hide();
}
else if ($('#ddlRoles').val() == 2)
{
$("#camilladefault").hide();
$("#camilladivtest").hide();
$("#camilladivtestFer").show();
}
else {
$("#camilladefault").show();
$("#camilladivtest").hide();
$("#camilladivtestFer").hide();
}
});
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
EXPERT CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window