Home > Web Front-end > JS Tutorial > body text

How to get the return value of js function through onclick event (less code)_Basic knowledge

WBOY
Release: 2016-05-16 15:48:30
Original
2085 people have browsed it

The specific process will not be described in detail, just go to the code:

Writing a pop-up box and binding the onclick event seems to be unable to control its return value. The code is as follows

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;
}
Copy after login

The above code is all the code to obtain the return value of the js function through the onclick event. I hope it will be helpful to everyone's future study work.

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template