js 创建 新标签 注册事件,和回调函数封装

// 删除成功提示
function alertMsg(text,sel,func){ 
	if($('#dlg_del_x').length > 0){
		$('#dlg_del_x').remove();
	}
	var model_div = document.createElement("div"); 
	model_div.setAttribute("class","modal fade bs-example-modal-sm-alert");
	model_div.setAttribute("id","dlg_del_x");
	
	var modal_sm = document.createElement("div"); 
	modal_sm.setAttribute("class","modal-dialog modal-sm");
	
	var modal_content = document.createElement("div"); 
	modal_content.setAttribute("class","modal-content");
	
	var modal_header = document.createElement("div"); 
	modal_header.setAttribute("class","modal-header");
	
	var modal_but_x = document.createElement("button");
	modal_but_x.setAttribute("class","close");
	modal_but_x.setAttribute("data-dismiss","modal");
	modal_but_x.setAttribute("aria-hidden","true");
	modal_but_x.innerText = "×";
	modal_header.appendChild(modal_but_x);
	
	var modal_h4 = document.createElement("h4");
	modal_h4.setAttribute("class","modal-title");
	modal_h4.innerText = "提示";
	modal_header.appendChild(modal_h4);
	
	var modal_body = document.createElement("div"); 
	modal_body.setAttribute("class","modal-body");
	modal_body.setAttribute("id","dlg_del_x_msg");
	modal_body.innerText = text;
	
	var modal_footer = document.createElement("div"); 
	modal_footer.setAttribute("class","modal-footer");
	
	if( sel ){	
		var modal_but_cancel = document.createElement("button");
		modal_but_cancel.setAttribute("type","button");
		modal_but_cancel.setAttribute("class","btn btn-default");
		modal_but_cancel.setAttribute("data-dismiss","modal");
		modal_but_cancel.innerText = "取消";
		modal_footer.appendChild(modal_but_cancel);
	}
	
	var modal_but_ok = document.createElement("button");
	modal_but_ok.setAttribute("type","button");
	modal_but_ok.setAttribute("class","btn btn-primary");
	modal_but_ok.setAttribute("data-dismiss","modal");
	modal_but_ok.innerText = "确定";
	modal_footer.appendChild(modal_but_ok);
	modal_but_ok.onclick = func;
	
	modal_content.appendChild(modal_header);
	modal_content.appendChild(modal_body);
	modal_content.appendChild(modal_footer);
	modal_sm.appendChild(modal_content);
	model_div.appendChild(modal_sm);
	
	document.body.appendChild(model_div);
	$('#dlg_del_x').modal("show");
} 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值