Monday, 05 August 2019 16:21

How to select paragraph element using jquery

Written by 
Rate this item
(0 votes)

You may be required to select all <p> elements with specific class 

or other ways using jquery.

 Following example shows how you do that where you select all 

paragraph elements which have class=our_para. 

Put this code in script section of your html document - 

$(document).ready(function(){

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

    $("p.our_para").hide();

  });

});

Then put this code in body section of your html document - 

<h2 class="our_para">This is a test heading</h2>

<p class="our_para">This is a test paragraph.</p>

<p>This is another paragraph.</p>

<button> Click here and view result </button>

Hope you like it, don't forget to share it.

Read 1323 times Last modified on Monday, 05 August 2019 16:27
Super User

Email This email address is being protected from spambots. You need JavaScript enabled to view it.

Latest discussions

  • No posts to display.