Scenario

Assume you have many divs in your aspx page and you have some string values inside these DIVs. Now let say you want to check if a DIV has "XXX" string values that make the background colorful. The following is my ASPX to do that:

  1. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Contains_In_jQuery.Default" %>
  2. <!DOCTYPE html>
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head runat="server">
  5. <title>Contains in jQuery</title>
  6. <script src="Scripts/jquery-2.1.4.min.js"></script>
  7. <script>
  8. $(document).ready(function () {
  9. $("div:contains('AMX')").css("background-color", "red");
  10. });
  11. </script>
  12. </head>
  13. <body>
  14. <form id="form1" runat="server">
  15. <div>Amol Malhotra - AMX</div>
  16. <div>Shambhu Sharma - AMX</div>
  17. <div>Hemant Chopra - HWN</div>
  18. <div>Rahul Saxena - AMX</div>
  19. <div>Yogesh Gupta - AMX</div>
  20. <div>Shraddha Gaur - AMX</div>
  21. <div>Abhishek Nigam - HWN</div>
  22. <div>Shweta Kashyap - AMX</div>
  23. <div>Saurabh Mehrotra - PHNX</div>
  24. <div>Mayank Dhulekar - USA</div>
  25. <div>Mehak Jain - HWN</div>
  26. <div>Rakesh Dixit - AMX</div>
  27. <div>Akhilesh Atwal - KS</div>
  28. </form>
  29. </body>
  30. </html>
Now run your application and the output will be as shown in Figure 1.

Run your Application
Figure 1

If you want to set more than one setting in CSS properties:
  1. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Contains_In_jQuery.Default" %>
  2. <!DOCTYPE html>
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head runat="server">
  5. <title>Contains in jQuery</title>
  6. <script src="Scripts/jquery-2.1.4.min.js"></script>
  7. <script>
  8. $(document).ready(function () {
  9. //$("div:contains('AMX')").css("background-color", "red");
  10. $("div:contains('AMX')").css({ "background-color": "yellow", "font-size": "140%", "color":"red" });
  11. });
  12. </script>
  13. </head>
  14. <body>
  15. <form id="form1" runat="server">
  16. <div>Amol Malhotra - AMX</div>
  17. <div>Shambhu Sharma - AMX</div>
  18. <div>Hemant Chopra - HWN</div>
  19. <div>Rahul Saxena - AMX</div>
  20. <div>Yogesh Gupta - AMX</div>
  21. <div>Shraddha Gaur - AMX</div>
  22. <div>Abhishek Nigam - HWN</div>
  23. <div>Shweta Kashyap - AMX</div>
  24. <div>Saurabh Mehrotra - PHNX</div>
  25. <div>Mayank Dhulekar - USA</div>
  26. <div>Mehak Jain - HWN</div>
  27. <div>Rakesh Dixit - AMX</div>
  28. <div>Akhilesh Atwal - KS</div>
  29. </form>
  30. </body>
  31. </html>
Run your application and the output will be as shown in Figure 2.

Run
Figure 2

You can use more than one check as in the following:
  1. <script>
  2. $(document).ready(function () {
  3. //$("div:contains('AMX')").css("background-color", "red");
  4. $("div:contains('AMX')").css({ "background-color": "yellow", "font-size": "100%", "color": "red" });
  5. $("div:contains('HWN')").css({ "background-color": "Skyblue", "font-size": "100%", "color": "white" });
  6. });
  7. </script>
put more than one check
Figure 3