自作jQueryプラグイン第二弾
https://github.com/uchikoba/jquery.checkboxSelectableLimitter
jQuery本体は別途読み込んでください。
Sample
<input type="checkbox" class="chk" value="1">チェック1
<input type="checkbox" class="chk" value="2">チェック2
<input type="checkbox" class="chk" value="3">チェック3
<input type="checkbox" class="chk" value="4">チェック4
<input type="checkbox" class="chk" value="5">チェック5
<script type="text/javascript" src="jquery.checkboxSelectableLimitter.js"></script>
<script type="text/javascript"><!--
$(document).ready(function () {
$('.chk').checkboxSelectableLimitter({
limit : 3,
callback : showLimit
});
});
function showLimit() {
// 残り個数を表示するような処理
}
// --></script>