jeremyll
asked on
Jquery: find any paragraph that is followed by an unordered list, then apply CSS rule
At the moment i have a css rule that applies a padding-bottom:13px; to all paragraphs.
Unfortunately, this gap doesn't look good when an unordered list immediately follows a paragraph.
So, I would like to apply a margin-top:-13px; to the unordered list.
I need jquery code that:
1. Searches inside a div content.
2. In this div content, find any paragraph that is followed by an unordered list, apply margin-top:-10px to the unordered list
I know the Jquery code to find the paragraph and apply css rule goes something like this I think,
$('p').css( "margin-top", "-13px" );
Sample HTML Code
Thanks!
Unfortunately, this gap doesn't look good when an unordered list immediately follows a paragraph.
So, I would like to apply a margin-top:-13px; to the unordered list.
I need jquery code that:
1. Searches inside a div content.
2. In this div content, find any paragraph that is followed by an unordered list, apply margin-top:-10px to the unordered list
I know the Jquery code to find the paragraph and apply css rule goes something like this I think,
$('p').css( "margin-top", "-13px" );
Sample HTML Code
<div class="content">
<p>This is the first paragraph</p>
<p>This is the second paragraph</p>
<p>This is a title </p>
<ul>
<li>the quick brown fox</li>
<li>jumped over </li>
<li>the lazy sheep</li>
</ul>
<p>This is another title </p>
<ul>
<li>the lazy sheep</li>
<li>jumped over </li>
<li>the quick brown fox</li>
</ul>
</div>
Thanks!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER