A5下载文章资讯

分类分类

怎么通过onclick事件获取js函数返回值(代码少)

2015-07-29 10:45作者:fang

具体过程不做详细叙述,直接上代码:

写一个弹出框,绑定onclick事件是好像控制不了它的返回值。代码如下

function createBtn(){

for(var i = 0; i < _this.btn.length; i++){

var btn = document.createElement('span');

btn.id = 'btn_' + i;

btn.innerHTML = _this.btn[i];

btn.style.padding = '5px 15px';

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;

}

}

function closeBox(){

var box = document.getElementById('msg_box');

box.remove();

if(this.id == 'btn_0'){

isBool = true;

}else{

isBool = false;

}

return isBool;

}

以上代码就是通过onclick事件获取js函数返回值的全部代码,希望对大家今后的学习工作有所帮助。

相关

说两句网友评论
    我要跟贴
    取消