---
title: "How to change in html data using JavaScript?"  
description: "How to change in html data using JavaScript?"  
author: "Ravi Vishwakarma"  
published: 2021-07-19  
canonical: https://answers.mindstick.com/qa/93759/how-to-change-in-html-data-using-javascript  
category: "web application"  
tags: ["javascript", "web application development", "web development"]  
reading_time: 1 minute  

---

# How to change in html data using JavaScript?

How to change in [html](https://www.mindstick.com/articles/12368/why-are-html-themes-the-first-selection-of-designers) [data](https://www.mindstick.com/articles/23186/how-becoming-a-data-analyst-can-be-a-lucrative-career) using [JavaScript](https://www.mindstick.com/articles/1530/design-a-simple-stylish-calculator-using-html-css-and-javascript)? using innerHTML .

## Answers

### Answer by Ethan Karla

We are use the innerHTML property for changing the inner data of html page. Syntax

```
document.JavaScript-Selector.innerHTML = new-data;
```

Eaxmple

```
<!DOCTYPE html>
<html lang='en' xmlns='http://www.w3.org/1999/xhtml'>
<head>
    <meta charset='utf-8' />
    <title>Inner HTML</title>
    <style>
    </style>
</head>
<body>
    <span>Some Data : </span>
    <input type='text' id='txt' placeholder='some data please' />
    <button onclick='changeData()' >Change Data</button>
    <p id='fill'></p>
    <script>
        function changeData() {
            var data = document.getElementById('txt').value;
            document.getElementById('fill').innerHTML += data;
        }
    </script>
</body>
</html>
```

\


---

Original Source: https://answers.mindstick.com/qa/93759/how-to-change-in-html-data-using-javascript

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
