Created
January 15, 2017 18:39
-
-
Save ybouhjira/b918f083719111062a4d9e5aae0963e0 to your computer and use it in GitHub Desktop.
Awesome attribute
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title> | |
</title> | |
</head> | |
<body> | |
<radiogroup data-show-when-checked="mydiv" data-enable-on="oui"> | |
<input type="radio" name="myradio" value="oui" > | |
<input type="radio" name="myradio" value="non"> | |
</radiogroup> | |
<div id="mydiv"> | |
Hello | |
</div> | |
<script type="text/javascript"> | |
$(function() { | |
var showAttr = 'data-show-when-checked'; | |
$('[' + showAttr + ']').change(function() { | |
var slef = $(this); | |
if (self.find('input:checked').val() === self.attr('data-enable-on')) { | |
$('#' + self.attr(showAttr)).show(); | |
} | |
}) | |
}) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment