更换单选与多选样式

HTML:
/*单选*/
/*多选*/
JQ:
/*单选*/
$(".jqTransformRadio").click(function () {
   $(".jqTransformRadio").removeClass("jqTransformChecked");
   $(this).addClass("jqTransformChecked");
});
$(".option-radio").click(function () {
   $(".jqTransformRadio").removeClass("jqTransformChecked");
   $(this).prev().prev().addClass("jqTransformChecked");
});

/*多选*/
$(".jqTransformCheckbox").click(function () {
   $(this).toggleClass("jqTransformChecked");
});
$(".option-checkbox").click(function () {
   $(this).prev().prev().toggleClass("jqTransformChecked");
});
CSS:
.jqTransformRadioWrapper, .jqTransformCheckboxWrapper{
  top: 7px;
  _zoom: 1;
  display: inline-block;
  margin: 0 4px;
  vertical-align: middle;
}
.jqTransformRadio {
  background: transparent url(../images/radio.png) no-repeat center top;
  vertical-align: middle;
  height: 16px;
  width: 18px;
  display: block;
  float: left;
  cursor: pointer;
  margin-left: 8px;
  margin-top: 2px;
}
.jqTransformCheckbox {
  background: transparent url(../images/checkbox.png) no-repeat center top;
  vertical-align: middle;
  height: 16px;
  width: 18px;
  position: relative;
  display: block;
  float: left;
  cursor: pointer;
  margin-left: 8px;
  margin-top: 2px;
}
.jqTransformChecked {
  background-position: center bottom;
}
.option-radio, .option-checkbox{
  color: #5a5a5a;
  font-weight: normal;
  padding-left: 0.3rem;
  cursor: pointer;
}
单选与多选img:

单选:


radio.png

多选:


checkbox.png

你可能感兴趣的:(更换单选与多选样式)