-1

I have these divs

<div id="content" style="display:none">**Content1 goes here**</div>
<div id="content" style="display:none">Content2 goes here</div>
<div id="content" style="display:none">Content3 goes here</div>
<div id="content" style="display:none">Content4 goes here</div>
<div id="content" style="display:none">**Content1 goes here too**</div>
<div id="content" style="display:none">**Content1 goes here again**</div>
<div id="content" style="display:none">Content4 goes here part 2</div>

I have my jquery contains selector

$( "div:contains('Content1')" ).css( "display", "block" );

If there's a match (i.e. Content1), then all matched DIVs will be displayed.

QUESTION: Is there a way to know how many matches occurred? For "Content1", it should say 3 records. Also, if there's no match, it will say "0 results".

Keavon
  • 6,837
  • 9
  • 51
  • 79
syntaxcode
  • 133
  • 2
  • 16

1 Answers1

0

Here is a simple example. I hope this helps :)

  var matches = $("div:contains('Content1')").length;

   alert(matches);

http://jsfiddle.net/silkherb/rvecpu5d/2/

jowi
  • 36
  • 2