怎么通过onclick事件获取js函数返回值(代码少)
具体过程不做详细叙述,直接上代码:
写一个弹出框,绑定onclick事件是好像控制不了它的返回值。代码如下
functioncreateBtn(){
for(vari=0;i<_this.btn.length;i++){
varbtn=document.createElement('span');
btn.id='btn_'+i;
btn.innerHTML=_this.btn[i];
btn.style.padding='5px15px';
btn.style.background='#E5E5E5';
btn.style.borderRadius='5px';
btn.style.marginRight='15px';
btn.style.cursor='pointer';
document.getElementById('btn_box').appendChild(btn);
//btn.onclick=closeBox;
}
}
functioncloseBox(){
varbox=document.getElementById('msg_box');
box.remove();
if(this.id=='btn_0'){
isBool=true;
}else{
isBool=false;
}
returnisBool;
}
以上代码就是通过onclick事件获取js函数返回值的全部代码,希望对大家今后的学习工作有所帮助。
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短