---
title: "How to change the inner data of html tag by using the .html() methods?"  
description: "How to change the inner data of html tag by using the .html() methods?"  
author: "Ethan Karla"  
published: 2021-07-28  
canonical: https://answers.mindstick.com/qa/93801/how-to-change-the-inner-data-of-html-tag-by-using-the-html-methods  
category: "web application"  
tags: ["web application development", "web development"]  
reading_time: 2 minutes  

---

# How to change the inner data of html tag by using the .html() methods?

How to change the inner [data](https://www.mindstick.com/articles/23186/how-becoming-a-data-analyst-can-be-a-lucrative-career) of [html tag](https://www.mindstick.com/interview/1837/what-is-the-difference-between-a-label-control-and-a-literal-control) by using the .html() [methods](https://www.mindstick.com/articles/13060/runny-nose-remedy-methods-that-work-best)?

## Answers

### Answer by Ravi Vishwakarma

jQuery [html](https://www.mindstick.com/articles/1530/design-a-simple-stylish-calculator-using-html-css-and-javascript)() method used to change the whole content of the selected elements. it change the content of selected elements with new html data.

```
Syntax $(selector).html ()  Return inner html of selected elements $(selector).html (content)  Set inner html of the selected elements $(selector).html (function (index, content))  Also set the inner html of selected elements by calling the function
```

```
<!DOCTYPE html>
<html>
<head>
    <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js'></script>
    <script>
        $(document).ready(function () {
            $('button').click(function () {
                $('.div1').html('Hello !!! i am added in div tag by using the html tag');
            });
        });
    </script>
    <style>
        .div1 {
            margin:10px;
            padding:10px;
            width:200px;
            height:200px;
            background-color:black;
            color:white;
        }
    </style>
</head>
<body>
    <button>Click me</button>
    <div class='div1'>
    </div>
</body>
</html>
```

![How to change the inner data of html tag by using the .html() methods?](https://answers.mindstick.com/questionanswer/55e36546-a0f6-43ea-bc5a-d788e0ce8b39/images/d742e566-f4eb-4d83-8e5f-8c8298da274e.png)

\


---

Original Source: https://answers.mindstick.com/qa/93801/how-to-change-the-inner-data-of-html-tag-by-using-the-html-methods

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
