lundi 22 février 2016

Ternary operator in Javascript and grouped sentences

I have the following ternary operator condition. Is there a way of the second if statement to be included somehow in line 1, so I don't need to make another if statement? The first condition, if true, should prepare the display status change and also the checkbox change.

    function change_properties(display){
        var display_r = ( display === 1) ? 'block' : 'none';
        if(display) jQuery("#checkbox").prop('checked',false); // THIS LINE - can it
         // be integrated in the ternary if-else condition above?
        jQuery("#field").css("display", display_r); 
    } // function

Aucun commentaire:

Enregistrer un commentaire