Created
June 1, 2012 22:30
-
-
Save iruslani/2855503 to your computer and use it in GitHub Desktop.
Change the url of the button depending if the checkbox is checked.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head></head> | |
<body> | |
<!-- This checkbox is checked and cannot be unchecked --> | |
<input type="checkbox" name="fw" id="freefw" checked disabled /> | |
<!-- If this checkbox changes, see jquery below --> | |
<input type="checkbox" name="av" id="freeavfw" /> | |
<a id="download" href="what/link/do/we/use"> | |
<img src="http://download.zonealarm.com/bin/images/cfu/yellow_freeupdate_btn.png" /> | |
</a> | |
</body> | |
<script> | |
$('#freeavfw').change(function(){ | |
// jquery shorthand conditioning statement. If true use link1 if not use link2. | |
var c = this.checked ? 'link1' : 'link2'; | |
// change the href attribute for the element ID = download to the value stored in 'c'. | |
$('#download').attr("href", c); | |
}); | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment