firstLoad

2017-11-01  本文已影响0人  小张宝

在加载ajax出来,为了不消耗资源,可以在class属性上加个firstLoad,当点击完移除firstLoad

然后在控制显示隐藏。

例如

$('.sideBarbox').on('click','.sideMenuName',function(){

var _this =$(this);

_this.addClass('on').parents('.sideParentMenu').siblings().children('.sideMenuName').removeClass('on');

var categoryCode = _this.attr('data-parentCode');$('.sideChildbox').find(".sideChildMenu[data-parentCode='"+categoryCode+"']").show().siblings().hide();

//_this.siblings('.sideChildMenu').show().parents('.sideParentMenu').siblings().children('.sideChildMenu').hide();if(_this.hasClass('firstLoad')){

$.ajax({url:"getCategoryByPCode",

type: "post",

data : {

},

dataType: "json",

success: function (data){

}

})

上一篇 下一篇

猜你喜欢

热点阅读