关于通过js给a标签增加onclick属性
var selfw2 = this;
//selfw2.loadData(nm);
return selfw2.loadData(nm).then(function(){
var cardInstance = selfw2.cardInstance(),
cardData = selfw2.cardInstance().dataSource,
currentRow = cardData != undefined ? cardData.tables('SRBIMNOTICEINFO').defaultView().currentItem : undefined;
debugger
var mc=currentRow.NI_TITLE.peek();
var xqtable = selfw2.cardInstance().dataSource.tables('SZYDTZGGXQB').peek();
var atttable = selfw2.cardInstance().dataSource.tables('SZYDATTACHMENT').peek();
var num=xqtable.length;
if(atttable.length>0){
var attname=atttable[0].ATTNAME;
var attpath=atttable[0].ATTPATH;
$('#Label1')[0].innerText="本次发版共涉及到"+num+"个功能点";
$('#IFrameFJ')[0].innerText=mc+":";
var oA=document.createElement('a');//创建a标签
oA.href='javascript:void(0)';//增加a标签的href属性
oA.innerHTML=attname;//给a标签添加内bai容
oA.setAttribute("onclick", "attDownload('"+nm+"','"+attname+"','"+attpath+"')");
oA.setAttribute("style", "text-decoration:none");
$('#IFrameFJ')[0].appendChild(oA);
}else{
var attname="";
var attpath="";
$('#Label1')[0].innerText="本次发版共涉及到"+num+"个功能点";
$('#IFrameFJ')[0].innerText="";
}
$('.gsp-pageHeader').find('h3:eq(0)')[1].innerHTML=mc;
});