Skip to content

Instantly share code, notes, and snippets.

@zackn9ne
Created December 4, 2014 20:58
Show Gist options
  • Select an option

  • Save zackn9ne/5fea2b2e7f6068a91a66 to your computer and use it in GitHub Desktop.

Select an option

Save zackn9ne/5fea2b2e7f6068a91a66 to your computer and use it in GitHub Desktop.
custom radial button
<div>
<label class=”label_radio”>
<input type=”radio” name=”radioList1” value=”1”> Option 1
</label>
<label class=”label_radio”>
<input type=”radio” name=” radioList1” value=”2”> Option 2
</label>
</div>
var customRadio = {
click: function (label) {
var _this = $(label);
_this.parent().find(".label_radio").each(function () {
$(this).removeClass("c_on");
});
_this.addClass("c_on");
},
init: function () {
$(".label_radio").each(function () {
var _this = $(this);
_this.click(function () {
customRadio.click(this);
});
if (_this.find("input").get(0).checked) {
_this.addClass("c_on");
}
});
}
}
$(document).ready(function () {
customRadio.init();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment