jQuery toggleClass example
Toggle class name on click in jQuery
by ChrisWong
HTML
<div>
<input type="button" class="btn btn-primary" value="Primary" />
<input type="button" class="btn btn-secondary" value="Secondary" />
<input type="button" class="btn btn-success" value="Success"/>
</div>
JavaScript
$(document).ready(function () {
$("input").on("keyup", function (event) {
if (event.keyCode == 40) {
$nextTabbable = $(this).next(":tabbable").length
? $(this).next(":tabbable")
: $(this).parent().next().find(":tabbable").first()
;
$nextTabbable.focus();
}
else if (event.keyCode == 38) {
$prevTabbable = $(this).prev(":tabbable").length
? $(this).prev(":tabbable")
: $(this).parent().prev().find(":tabbable").last()
;
$prevTabbable.focus();
}
});
});