1. jQuery包装多个选择器的click事件
// "告警等级"选择 $("#filter_level_1, #filter_level_2, #filter_level_3, #filter_level_4").click(function () { onclickAlarmFilterLevel(this.id.split(‘filter_level_‘)[1]); });
上面代码等效于:
// 点击1级告警 $("#filter_level_1").click(function () { onclickAlarmFilterLevel(this.id.split(‘filter_level_‘)[1]); }); // 点击2级告警 $("#fi#filter_level_2").click(function () { onclickAlarmFilterLevel(this.id.split(‘filter_level_‘)[1]); }); // 点击3级告警 $("#filter_level_3").click(function () { onclickAlarmFilterLevel(this.id.split(‘filter_level_‘)[1]); }); // 点击4级告警 $("#filter_level_4").click(function () { onclickAlarmFilterLevel(this.id.split(‘filter_level_‘)[1]); });
2. 选择器过滤
// "修改"单个施工截面信息 $(‘#tableSection‘).on(‘click‘, ‘a.aModifySectionModal‘, onmodifySection);
以上代码中, ‘a.aModifySectionModal‘ 是 ‘#tableSection‘ 表格中的某一个"修改"单元格:
var std = ‘<td><a href="#getSectionModal" class="aViewSectionModal" data-toggle="modal">‘ + ‘查看‘ + ‘</a> | <a href="#addSectionModal" class="aModifySectionModal" data-toggle="modal">‘ + ‘修改‘ + ‘</a> | <a href="#deleteSectionModal" data-toggle="modal" onclick="confirmDeleteSection(this,‘ + item.sectionId + ‘)">‘ + ‘删除‘ + ‘</a> | <a href="#deleteSectionModal" data-toggle="modal" onclick="confirmDisableSection(this,‘ + item.sectionId +‘,‘+ item.isDelete + ‘)">‘ + disableTxt + ‘</a></td>‘;
时间: 2024-10-09 20:31:12