任何人都可以在IE8上给我解决此问题的解决方案。我有这个:html:
<label>
<input type="checkbox" checked /><i class="icon-fixed-width icon-check"></i> Three
</label>
CSS:
[type=checkbox] { display: none; }
label { cursor: pointer; }
[class*=icon-].icon-fixed-width { text-align: left; }
jQuery:
$("[type=checkbox]").change(function () {
$checkbox = $(this)
$icon = $checkbox.siblings("[class*=icon-]")
checked = $checkbox.is(":checked")
$icon.toggleClass('icon-check', checked)
.toggleClass('icon-check-empty', !checked)
});
在现代浏览器上都可以正常工作,但是在IE8上都无法工作。这里怎么了?小提琴:
ty。
只需在每条JavaScript行之后添加一个分号即可。我认为当您不使用;
$("[type=checkbox]").change(function () {
$checkbox = $(this);
$icon = $checkbox.siblings("[class*=icon-]");
checked = $checkbox.is(":checked");
$icon.toggleClass('icon-check', checked).toggleClass('icon-check-empty', !checked);
});
小提琴