如果我不勾選這兩個框,此工作正常。不知道如何解決它。用複選框和jquery顯示隱藏元素 - jsfiddle示例
$(".home-check").live('click', function() {
if ($(".home-check").is(':checked')) {
var ident = $(this).attr('id');
$('.' + ident).hide();
} else {
var identt = $(this).attr('id');
$('.' + identt).show();
}
});
<p><input class="home-check" id="water" type="checkbox" name="gethired" />Fire - Only Show Fire</p>
<p><input class="home-check" id="fire" type="checkbox" name="hire" />Water - Only Show Water</p>
<li class="fire">Fire</li>
<li class="water">Water</li>
<li class="fire">Fire</li>
<li class="water">Water</li>
<li class="fire">Fire</li>
<li class="water">Water</li>
http://jsfiddle.net/cip691/AeyAL/2/
目前尚不清楚您期望的行爲... – 2012-04-17 19:30:29