How to use Adding Method in HTML JQuary

This article describe about jQuary HTML Adding Text Method.
  • 1732

Adding html text method

Adding method add a text in a paragraph, by using append() method.

Also adding method add a text in a paragraph, by using prepend() method.

Syntax

$("selector").append("text");

Example

<!DOCTYPE html>

<html>

<head>

<script type="text/javascript" src="jquery.js"></script>

<script type="text/javascript">

    $(document).ready(function () {

        $("button").click(function () {

            $("p").append(" <b>.Net Heaven</b>.");

        });

    });

</script>

</head>

 

<body>

<h2>This is a jQuery</h2>

<p>This is a HTML.</p>

<p>This is add text.</p>

<button>Add</button>

</body>

</html>

 

Output

 

 op1.jpg

After click this button

op2.jpg

You may also want to read these related articles here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

© 2019 DotNetHeaven. All rights reserved.