Knowledge Walls
Gopal Rao
Mumbai, Maharashtra, India
Passcode:
How to add text in jquery in Jquery functions of JQuery Examples
2894 Views
Note 
.text() function used to get content from html tag.
Example: 1 How to get text from html tag.

.text('welcome').
Example: 2 How to add text to html tag.

Note:
If you use html() can add the html tags in page.
Example: 1 How to get text from html tag
<html>

<head>
    <title>HTML-JQuery</title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>

    <script type="text/javascript">
        $(function () {
            alert($(".defined").text());
        });
    </script>
    <style type="text/css">
        .added {
            color: red;
        }
    </style>
</head>

<body>
    <div class="defined">
        <div class="html">hello welcome to This page.</div>
    </div>
</body>

</html>
Example: 1 Demo 
Example: 2 How to add text to html tag
<html>

<head>
    <title>HTML-JQuery</title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>

    <script type="text/javascript">
        $(function () {
            $(".html").text('welcome');
        });
    </script>
    <style type="text/css">
        .added {
            color: red;
        }
    </style>
</head>

<body>
    <div class="defined">
        <div class="html"></div>
    </div>
</body>

</html>
Example: 2 Demo 
Next Topics
Next lessons of current book.
Best Lessons of "JQuery Examples"
Top lessons which are viewed more times.
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details