Is it possible to create a conditional by assigning the conditional within a value? I did it the way it did, but it did not work:
HTML
<input type="radio" name="pg1" value="SIM"> TESTE <BR/>
<input type="radio" name="pg1" value="NÃO"> TESTE 2
<div id="esconde">
<p>NADA</p>
</div>
JAVASCRIPT
$(document).ready(function(){
$("[name='pg1']").click(function(){
var valor = $(this).val();
divShowOrHide({
//valorEscolhido: valor,
condicional: valor+" === SIM",
hideDiv: "#esconde"
});
});
});
function divShowOrHide(obj){
//alert(obj.condicional);
if(obj.condicional){
$(obj.hideDiv).show();
} else {
$(obj.hideDiv).hide();
}
}
Jsfiddle: link