mercredi 21 octobre 2015

Log all items of checked checkboxes to console

I have three checkboxes which have a class name of (names). I am trying to say if the checkbox is checked log the value to the console.

if( $('.names').is(':checked') ){
        console.log($('.names').val()); 
    }else{
        console.log('null'); 
    }

However, this is only logging the first value to the console (when there is more than one ticked).

Do i need to create an array and log that?




Aucun commentaire:

Enregistrer un commentaire