需求:经常会遇到一种情况,选中某个元素,要求添加单独的样式,这时候我们一般用addClass('active'),同时要移除上一个添加active类的元素的active样式
{
event:'click',
selector:'li',
callback:function (e) {
//添加单独的样式
$(e).siblings().removeClass('bgColor');
$(e).addClass('bgColor');
//当前下拉框所属字段
this.data.supportAllData.currentField = $(e).parents('.person-select-box').attr('data-id');
//选中的数据的格式
this.data.supportAllData.choose={
value:$(e).attr('data-value'),
name:$(e).attr('title'),
py:$(e).attr('data-py')||[]
};
this.el.find('.person-select-box').attr('data-value',$(e.currentTarget).innerText);
}
},