I have a link when clicked by the user will uncheck a checkbox.
When the checkbox is unchecked, I want a div to be hidden. Only when the checkbox is checked the div is displayed.
Both scripts work independently, but together they do not. When I refresh the page, the link to uncheck the checkbox works correctly but the div is displayed.
I need help to combine these two scripts together to ensure the div is displayed when the checkbox is checked AND the checkbox is unchecked by a link.
HTML:
<a id="uncheck-all" href="#sharestory2" class="share_cont1">Continue</a>
<input type="checkbox" name="agreeCheckbox" value="Accept" onchange="toggleLink(this);">
<div class="share_cont_PRO" id="agreeLink" style="display:none;"><a href="#sharestory3" class="share_contPRO">Proceed To Sharing</a></div>
SCRIPT:
$(document).ready(function() {
$('#uncheck-all').click(function(){
$("input:checkbox").attr('checked', false);
});
});
function toggleLink(checkBox)
{
var link = document.getElementById("agreeLink");
if (checkBox.checked)
link.style.display = "inline";
else
link.style.display = "none";
}
Aucun commentaire:
Enregistrer un commentaire