mardi 25 août 2015

jQuery if statement for two select items

If two select elements are set to a "yes" I want a <div> to show. This code works for one of them but how do I add a second "if"?

<select id="select1">
    <option value="No">No</option>
    <option value="Yes">Yes</option>
</select>
<select id="select2">
    <option value="No">No</option>
    <option value="Yes">Yes</option>
</select>

$('#select1').change(function() {
    if($(this).val() == 'Yes') {
        $('#divtest').show();
    }
});

Aucun commentaire:

Enregistrer un commentaire