我在获取两个标签的id(aId,bId)之后,想将这两个标签拼在一起,然后打印出来
for(var i = 0;i<aLi.length;i++){
aLi[i].onclick = function(){
var aTxt = this.innerHTML;
window.aId = this.id;
document.getElementById('ss').innerHTML = aTxt;
}
}
for(var j = 0;j<bLi.length;j++){
bLi[j].onclick = function(){
var bTxt = this.innerHTML;
window.bId = this.id;
document.getElementById('cc').innerHTML = bTxt;
}
}
var addId = aId + bId;
var oBtn = document.getElementById('btn');
oBtn.onclick = function(){
alert(addId);
}
这么写可以么?