- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
JavaScript display the result of a function as HTML?
To display the result of a function as HTML, you can use −
document.getElementById().innerHTML.
Example
Following is the code −
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> <body> <div> <input type="text"> <br> <input type="text"> <br> <input type="radio"> <br> <input type="text"> <br> <input type="radio"> <br> </div> <br> <span id='totalNumberOfTextBox'></span> </body> <script> total_number_of_check_box(); function total_number_of_check_box() { var inputObj = document.getElementsByTagName("input"), counter = 0; for (var i = 0; i < inputObj.length; i++) { if (inputObj[i].type == "text") { counter++; } } document.getElementById('totalNumberOfTextBox').innerHTML = "Total Number of text box is=" + counter; } </script> </html>
To run the above program, save the file name anyName.html(index.html). Right click on the file and select the option “Open with live server” in VS Code editor.
Output
This will produce the following output −
- Related Articles
- Display the result difference while using ceil() in JavaScript?
- JavaScript outsider function call and return the result
- Update the table by calculating the sum and display the result as last column value
- How to invoke a JavaScript Function as a function?
- How to display HTML element with JavaScript?
- Display result of a table into a temp table with MySQL?
- How to subtract elements of two arrays and store the result as a positive array in JavaScript?
- Passing a function as a callback in JavaScript
- Add two consecutive elements from the original array and display the result in a new array with JavaScript
- How to call a JavaScript function in HTML?
- How to invoke a JavaScript Function as a method?
- Sort a list in MySQL and display a fixed result at the end of the column?
- JavaScript: How to loop through all DOM elements on a page and display result on console?
- Display substrings of different length with a single MySQL query and combine the result
- Display the count of duplicate records from a column in MySQL and order the result

Advertisements