How to use Contains Selector Method in JQuery

This article describe about contains Selector Method in JQuery.
  • 2181

Use :contains Selector method in jQuery

In this method, we select elements contains the specified string.

We put text element in a selected element, or in a child element.

The :contains method mostly use to another selector.


<!DOCTYPE html>



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

<script type="text/javascript">

    $(document).ready(function () {

        $("p:contains(is)").css("background-color", "yellow");





<h1>This is jQuery</h1>

<p class="intro">This is a part of life</p>

<p>I am Aman</p>

<p>My best friend is Varun</p>

Who is your favorite:

<ul id="choose">

<li>My Self</li>

<li>My Friends</li>






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

© 2020 DotNetHeaven. All rights reserved.