dimanche 3 avril 2016

Jquery checbox if statement

I don't know why this code print on the console both of the If statement case at the same time.

this is the HTML

<!--PRIMA RIGA FOTO STYLING --> 
<div class="row ">   
    <div class="col-md-5 col-md-offset-1 col-centered piege">
        <input type="checkbox" id="piega1" class="piege servizioSection2 " name="imgSection2"value="PiegaByWellaProfessionals">
        <label  class="piega labelStylingImg " for="piega1">
            <img src="img/piega1.png" for="piega1" alt="" class="img-responsive immaginePiega ">
        </label>
        <h1 class="immagineTitoloPiega">PIEGA BY WELLA PROFESSIONALS</h1>
    </div>
    <div class="col-md-5  col-centered piege">
        <input type="checkbox" id="piega2" name="imgSection2" class="piege servizioSection2" value="Piega By System Professionals">
        <label for="piega2" class="piega labelStylingImg">
            <img src="img/piega2.png" for="piega2" alt="" class="img-responsive immaginePiega">
        </label>
        <h1 class="immagineTitoloPiega">PIEGA BY SYSTEM PROFESSIONALS</h1>
    </div>
</div>

and this is the jquery

 if ($('input.servizioSection2').is(':checked')) {

    console.log('ciao')
} else {
    console.log('arrivederci')
} ;




Aucun commentaire:

Enregistrer un commentaire