点击空白地方 隐藏某个下拉框或者其他数据
//ONE
$("*").click(function (event) {
if (!$(this).hasClass("brand-more") ){
$('#car_show').hide();
}
event.stopPropagation(); //阻止事件冒泡
});
//TWO
window.onclick = function(event){
var e = event || window.event;
// console.log(e.target.className);
if(e.target.className == 'rt_content' || e.target.className == 'rt_wrap content'){
$(".city-select__option").hide();
}
}
//第一个有弊端 估计是层级关系原因 当时我footer.html中存在一个点击事件 因为当前页面有 $("*") 所以没被触发footer页面的事件
//第二个 e.target.className 名称来处理点击哪 会关闭谁谁...
JQ的parseInt 强制类型转换
var count = 0;
conut =count + 1; //count变量会误认为 + 号为 字符串连接符
//需要强制转换
conut = parseInt(count) + 1;
JQ 我也不知道啥玩意 两种写法 自定义方法名称
$(function(){
$('.city-select__selected').click(function(){
if($('#city_idTwo').is(':hidden') == false){
$('#city_idTwo').hide();
}else{
$('#city_idTwo').show();
var hide_city = $('#hide_city').val();
var list_child = $('.list_childcity');
}
})
window.city_zm=function(_this){
var zm = $(_this).html();
$(_this).addClass('active');
}
window.city_xz=function(city_id,_this){
$(_this).addClass("active")
$(_this).siblings().removeClass("active");
}
})
//第二种写法
$(function(){
$('.city-select__selected').click(function(){
if($('#city_idTwo').is(':hidden') == false){
$('#city_idTwo').hide();
}else{
$('#city_idTwo').show();
var hide_city = $('#hide_city').val();
var list_child = $('.list_childcity');
}
})
});
function city_zm(_this){
var zm = $(_this).html();
$(_this).addClass('active');
}
function city_xz(city_id,_this){
$(_this).addClass("active")
$(_this).siblings().removeClass("active");
}
JQ 对等式
$(function(){ }) == $(document).ready(function(){ })
//注意一下 如果在html 可以不必上两个标签使用 那时页面元素肯定完成
//在 style下的时候 用这两 在处理
//自动消失
$("#bmtip_box").delay(1000).hide(0);
JQ性能最好的位置
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190704143155549.png)