Forked from joe-watkins/gist:00a1bd83fec29048f4ed
Last active
August 29, 2015 14:22
-
-
Save jackmakesthings/0af0ebc2140ea2de353a to your computer and use it in GitHub Desktop.
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
/*! | |
* toggleAria.js | |
* Author: Joe Watkins | |
* usage: | |
HTML | |
<button aria-pressed="false">Show Content</button> | |
$("button").on("click", function(){ | |
$(this).toggleAria({aria: "pressed"}); | |
}); | |
* | |
*/ | |
(function($){ | |
$.fn.toggleAria = function(options) { | |
var defaults = { | |
wrapper: this, | |
aria: "" | |
}, | |
options = $.extend(defaults, options), | |
o = options, | |
currentState = $(o.wrapper).attr("aria-"+o.aria), | |
newState; | |
if(currentState == "false"){ | |
newState = "true"; | |
}else{ | |
newState = "false"; | |
} | |
$(o.wrapper).attr("aria-"+o.aria,newState); | |
}; // $.fn | |
}(jQuery)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment