UncleCoder.com

UncleCoder.com

Free programming examples and instructions

jQuery appent to p tag

Code and example for how to append html tags to p tag using jQuery

by Athil


Posted on 13 May 2017 Category: jQuery Views: 685

Edited on 03 Jun 2017


DEMO

 

Hi, Here I am going to show how to append HTML to <p> tags.

  $("#Myp").append("<b>My new text</b>");

Full Code

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Demo for jQuery append to p tag</title>
       <script type="text/javascript" src="js/jquery.min.js" ></script>
    
</head>
<body>
    <h1>Demo for jQuery append to p tag </h1>

    <p id="Myp">my paragraph</p>
    <button id="btnAppend" type="submit">Append to p</button>
    <script>

        $("#btnAppend").click(
        function () {
            $("#Myp").append("<b>My new text</b>");
        });
        </script>

</body>
</html>


Leave a Comment:


Advertisement