How to get paragraph or p tag text using jquery

Using below program we can learn how to get paragraph text using jquery.


<!DOCTYPE>

<html>
<head>
    <title>How to get paragraph text using jQuery</title>
         <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
</head>
<body>
    <!--this is paragraph-->
    <p>This is www.jqueryexamplecode.blogspot.com. </p>
    <p class="example">www.jqueryexamplecode.blogspot.com</p>
    
    <script>
    //accessing the all paragraph element data
        alert($('p').text());

        //getting only specific paragraph data using class attribute
        alert($('p.example').text());
    </script>
    
</body>
</html>


Share this post :

Post a Comment

Please give your valuable feedback on this post. You can submit any ASP.NET article here. We will post that article in this website by your name.

 
Support : Ranga Rajesh Kumar
Copyright © 2012. ASP.NET Examples - All Rights Reserved
Site Designed by Ranga Rajesh Kumar