Checar checkbox por outros elementos
by Jairo Fontes
HTML
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<div class="box marginBottomM" style="background-color:#2ECC71;">
<img class="pull-left" src="http://ava.i.gigrows.com/img/produtos/produto14/64x64.png" alt="icone avaliação">
<p class="pull-left">
<span class="small">Módulo</span><br>
Avaliação Física <br>
R$ 490,00
</p>
<label class="checkbox">
<span class="iconeCheck fa fa-check" style="display: none;">X</span>
</label>
<input class="check" name="dominio[2][]" type="checkbox" value="">
</div>
CSS
.box {
color: #ecf0f1;
padding: 20px;
cursor: pointer;
width: 400px;
border-bottom: 10px solid rgba(255, 255, 255, 0.5);
position:relative;
}
.checkbox {
position:absolute;
top: 60px;
right:30px;
font-size: 40px;
height: 44px;
width: 44px;
padding: 0;
background: #ecf0f1;
border: 2px solid #7f8c8d;
}
.iconeCheck{
color:#000;
}
JavaScript
$(".box").click(function(){
if($('.check').hasClass('not')){
return false;
}
$(this).children(".checkbox").children(".iconeCheck").fadeToggle("fast");
$(this).children(".check").each(function () {
if ($(this).is(':checked'))
$(this).prop('checked', false);
else
$(this).prop('checked', true);
});
});