How to obtain js function return values through the onclick event (less code) _ basic knowledge-js tutorial

Source: Internet
Author: User
This article mainly introduces how to obtain the js function return value through the onclick event. If you need it, you can refer to the specific process without further details and directly go to the Code:

Write a pop-up box and bind the onclick event as if it cannot 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 that gets the js function return value through the onclick event, hoping to help you in your future study.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.