Skip to content

Instantly share code, notes, and snippets.

@alphillips
Last active September 12, 2016 03:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alphillips/2fff831b2aef1c87c660d09ca903acf4 to your computer and use it in GitHub Desktop.
Save alphillips/2fff831b2aef1c87c660d09ca903acf4 to your computer and use it in GitHub Desktop.
Button group for UI-Kit sample
<style>
.button-group > button{
margin-left: 1px;
margin-right: 0;
background-color: #ffffff;
color:#115361;
}
.button-group > button.button-group-selected {
background-color: #18788d;
color:#fff;
}
.button-group > button.button-group-unselected {
background-color: #ffffff;
color:#115361;
}
div.button-group {
margin-top: 10px;
}
</style>
<script>
document.addEventListener("DOMContentLoaded", function(event) {
$('.button-group').each(function(){
$(this).children().each(function(){
$(this).addClass("button-group-unselected");
$(this).click(function(){
$(this).siblings().removeClass("button-group-selected");
$(this).removeClass("button-group-unselected");
$(this).addClass("button-group-selected");
});
})
});
/* get the selected value
$('.button-group.contact > button').each(function(){
if($(this).hasClass('button-group-selected')){
console.log($(this).text());
}
});
*/
</script>
<form>
<fieldset>
<legend><u>How</u> should we contact you?</legend>
<div class="button-group contact">
<button onclick="return false;">Email</button>
<button onclick="return false;">SMS</button>
<button onclick="return false;">Call</button>
<button onclick="return false;">Here</button>
</div>
</fieldset>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment