I am facing a weird problem. I do need to show a popup when checking a checkbox. It works fine, but the same popup appears even during unchecking.
<af:objectImage id="agreementCheckBoxImg" source="/base/images/spacer.gif" styleClass="jqTransformCheckbox" onclick="displayPopup(this.id,'main\\\\:content\\\\:Popupregion\\\\:Popup','520px','260px');return false;"/>
<script type="text/javascript">
function displayPopup(buttonId,popId,width,height) {
var eminputSelf = $("#main\\:content\\:check");
if (eminputSelf.attr("checked") == true) { // check box condition works fine
alert('returning do not show popup');
} else {
$('#'+needHelpId).colorbox({ open:true, title:'',innerWidth:interWidth, innerHeight:innerHeight,close:'shutdown', inline:true, href:popId , onOpen:function(){ $(popId ).show();}, onCleanup:function(){ $(popId ).hide();}});
}
}
</script>
The alert is coming during uncheck, but the popup also coming.
Please help. Thanks in advance.
Try using:
prop()returns boolean values and changes with the checkbox state, whileattr()does not.http://api.jquery.com/prop/