简易复选框样式设置
受这篇文章启发 一大堆的 CSS 自定义复选框
主要是
<input type="checkbox" id="checkbox-1" /> <label for="checkbox-1">Check?</label> #checkbox-1 { display: none; } #checkbox-1 + label { color: red; } #checkbox-1:checked + label { color: blue; }
自己写的
<head> <meta charset="UTF-8"> <title>Document</title> <script type="text/javascript" src="jquery-1.11.2.min.js"></script> <style type="text/css"> #checkbox-1 { display: none; } #checkbox-1 + label { background-image: url(check_null.png); background-position: 0 0; border: 0; background-size: 14px 14px; } #checkbox-1:checked + label { background-image: url(check_all.png); background-position: 0 0; border: 0; background-size: 14px 14px; } label { width: 14px; height: 14px; display: block; } </style> </head> <body> <input type="checkbox" id="checkbox-1" /> <label for="checkbox-1"></label> <script type="text/javascript"> $('#checkbox-1').change(function () { if($("#checkbox-1").is(':checked')) { console.log('abc') } }) </script> </body>