日期:2014-05-16 浏览次数:20412 次
$(function(){
  $("label").click(function(){
  	if($(this).children("input[name='checkbox']").attr("checked")=='checked'){
		$(this).children('input').removeAttr("checked");
		$("#"+$(this).children('input').val()).parent().remove();
	}else{
		$(this).children('input').attr("checked","checked");
		$(this).parent().addClass("on");
		$(".options").show();
		var element='<li>'+$(this).attr("title")+'<a href="#" onclick="delCon(this)" id="'+$(this).children('input').val()+'" title="删除此条件"></a></li>';
		$("#conditions").append('<li>'+$(this).attr("title")+'<a href="#" onclick="delCon(this)" id="'+$(this).children('input').val()+'" title="删除此条件"></a></li>');
	}
	//alert($("input:checked").length);
	if($("input:checked").length>0){
	    $("#cover").css('display','block');
		var conditions="";
		var url='sub/getHotelList.php?v='+Math.random();
		$("input:checked").each(function(data){
			conditions+=$(this).val()+",";
			
		});
		$.post(url,{items:conditions},function(data){
		    //alert(data);
		    $("#hotellist").html(data);
			$("#cover").css('display','none');
			$("#content").html(data);
		});
	}
  });
});
<dl class="fit">点击以后会执行两次?求指教
<dt>星级</dt>
<dd><input type="checkbox" id="star5" name="checkbox" value="5" /><label for="star5" title="五星">五星</label></dd>
<dd><label for="star4" title="四星"><input type="checkbox" id="star4" name="checkbox" value="4" />四星</label></dd>
<dd><label title="三星"><input type="checkbox" name="checkbox" value="3" />三星</label></dd>
<dd><label title="经济"><input type="checkbox" name="checkbox" value="2" />经济</label></dd>
</dl>
<dl class="fit">
<dt>房价</dt>
<dd><label title="600元以上"><input type="radio" name="pfilter" value="1" title="600元以上" />600元以上</label></dd>
<dd><label title="300-600元"><input type="radio" name="pfilter" value="6" />300-600元</label></dd>
<dd><label title="150-300元"><input type="radio" name="pfilter" value="7" />150-300元</label></dd>
<dd><label title="150元以下"><input type="radio" name="pfilter" value="8" />150元以下</label></dd>
</dl>
<label onclick="alert(0)"><input type="checkbox" name="tt" value="1" />点一下执行两次onclick</label>