前端js
1、获取当前点击的元素
$('html').click(function(e){ if(window.bzStatus){ return; } var actInfoPop = $('#actInfoPop'), curObj = $(e.target); //时间插件 if(curObj.closest("div[name='calendarForm']").length == 1) { return; } var status = (!curObj.closest('#actInfoPop').length && !curObj.closest('#partnerAdd').length && !curObj.closest('#sellAdd').length && !curObj.hasClass('act-name') && !curObj.closest('#alertPop').length && !curObj.hasClass('float-wrap').length && !curObj.closest('#distributePop').length); //.... });
2、单选按钮及下拉列表选中
createPop.find($("select[name='pointnum'] option[value='1']")).attr("selected",true);//默认选中 1位 createPop.find('input:radio[name="ismoney"][value="0"]').attr('checked', true);//默认选中 非货币
3、ajax传递对象
var extrfield = {}; extrfield.id = id; extrfield.extraid = extraid; extrfield.fieldname = fieldname; $.ajax({ type: 'POST', url: '#RPL:pjPath#/system/extrfieldsave', dataType :'json', data : extrfield, async:false, success : function(data){ if('0' == data) { $('#createpop').find('.big-gray-btn').click(); alertPop('操作失败'); } else { $('#createpop').find('.big-gray-btn').click(); //重新加载字段 var table = $("#infopop").find('tbody'); table.html(''); var ajaxData = {}; ajaxData.extraid = extraid; $.ajax({ type :'post', url : '#RPL:pjPath#/system/extrfieldmanagebyextraid', dataType :'json', data : ajaxData, async:false, success : function(data){ var data = eval("("+data+")"); var extrfields = data.extrfields; if(extrfields) { for (var i = 0; i < extrfields.length; i++) { } } } }); alertPop('操作成功'); } },error: function(){ alertPop('操作失败'); return false; } });
另外一种情况
var ajaxData = {}; ajaxData["searchconditionDto[" + i + "].fieldname"] = 'xxx'; ajaxData["searchconditionDto[" + i + "].operator"] = 'yyy';
4、js拼接html字符串
/*var str = '<tr>\ <td><input type="text" value="'+value+'" data-value="" readonly/></td>\ <td>\ <select>\ <option value="0">非默认值</option>\ <option value="1" '+seled+'>默认值</option>\ </select>\ </td>\ <td>\ <span class="e-icon mr10"></span>\ <span class="ddel-icon"></span>\ </td>\ </tr>';*/
5、jQuery 几个关键字
$('#workTab').delegate('.refuse-btn','click',function(){ var msgPop = $('#msgPop'); trObj= $(this).closest('tr'), formName = trObj.find('td').eq(1).text(), formId = trObj.data('id'); $('#auditingForm').find('input[name="id"]').val(formId);//id });
相关推荐
liduote 2020-11-13
chenhaotao 2020-11-13
localhost0 2020-11-12
小秋 2020-11-12
lxhuang 2020-11-03
学习web前端 2020-10-27
小焊猪web前端 2020-10-24
杏仁技术站 2020-10-23
南昌千网科技 2020-10-18
liduote 2020-10-16
BlueSkyUSC 2020-10-15
Doniet 2020-10-08
zjutzmh 2020-09-25
PncLogon 2020-09-24
趣IT 2020-09-22
杏仁技术站 2020-09-18
拾光璇旅 2020-09-17
kiven 2020-09-11
lfbooo 2020-09-09