I'm trying to generate events from user action in a checkbox list. The idea is simple: Manage the appearance of "divs" content on the screen from the ".toogle ()" jquery method in checkbox in html.
The method works for other input elements, such as type input (type="text"), but not in the checkbox.
OBS: I am using HTML, CSS3, BOOTSRAP and JQUERY to make the screen
But to simplify the solution, I plan to ask you guys to just generate an "alert" command when the user checks or unchecks a checkbox using javascript or jQuery.
//JQUERY/JS - OPÇÃO 1
function teste(){
alert("foi !");
}
if($("#selecionado").is(':checked')){
teste();
}
//JQUERY/JS - OPÇÃO 2
x= $("#selecionado").prop( "checked");
$("#selecionado").change(
function(){
if(x==true){
alert("merda");
}
}
);
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script><linkhref="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script><divclass="col-lg-8">
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox" id="selecionado" class="chk-services"/>
</span>
<label type="text" class="form-control label-form" >
<strong>PRICING</strong> - Valorização de Instrumentos Financeiros
</label>
</div>
</div>