1

I have one question. I want to know how to solve the following example:

I have html site like this:

<div>
    <p><strong>Title 1</strong></p>
    <p>Content 1</p>
    <p>Content 2</p>
    <p><strong>Title 2</strong></p>
    <p>Content 1</p>
    <p>Content 2</p>
    <p>Content 3</p>
</div>

How to select "Content's" from "Title 2" like this:

Content 1

Content 2

Content 3

Thanks for answer!

Daniel Jaušovec
  • 217
  • 5
  • 15

1 Answers1

3

if you want to do this with javascript you can just hide all the p elements and show the ones after title 2 like this:

$(document).ready(function() {
    $("p").hide();
    $("p:contains('Title 2')").nextAll().show();
});

Here is a jsfiddle of it working:

http://jsfiddle.net/LKSRh/

If you wanted to get the paragraphs of title 1 but before title 2 you would do:

$(document).ready(function() {
    $("p").hide();
    $("p:contains('Title 1')").nextUntil("p:contains('Title 2')").show();
});
Avitus
  • 15,640
  • 6
  • 43
  • 53