mercredi 22 juillet 2015

JQuery If elements have a value

I'm trying to do what I believe to be a very simple JQuery function. I'm just trying to populate a label with a predetermined value. Before this happens, I want to make sure that 3 elements (one textbox and two selectboxes) all have values in them. Here's my code:

$(document).ready(function ($) {
    if($('#textbox').val() && $('#selectbox1').val() && $('#selectbox2').val()) {
        $('#label').text('value');
    }
});

Aucun commentaire:

Enregistrer un commentaire