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; }
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.