lauthiamkok
11-07-2009, 05:28 PM
Hi,
How can I find if each of the <p> tags contains <img> tag, then style the <p> tags which contain <img> inside them?
I have pre-set all <p> will have this style,
<style>
p { padding:0px 0px 20px 0px;}
</style>
The function to re-style the <p> which contains <img> inside them,
$(document).ready(function(){
if ($('p img').length >0) {
$("p img").css({
padding: '0px'
});
}
});
The HTML,
<div id="content">
<p><img src="img.jpg"/></p>
<p>Lorem ipsum dolor sit amet</p>
<p><img src="img.jpg"/></p>
<p>Lorem ipsum dolor sit amet</p>
</div>
Is it possible?
Thanks,
Lau
How can I find if each of the <p> tags contains <img> tag, then style the <p> tags which contain <img> inside them?
I have pre-set all <p> will have this style,
<style>
p { padding:0px 0px 20px 0px;}
</style>
The function to re-style the <p> which contains <img> inside them,
$(document).ready(function(){
if ($('p img').length >0) {
$("p img").css({
padding: '0px'
});
}
});
The HTML,
<div id="content">
<p><img src="img.jpg"/></p>
<p>Lorem ipsum dolor sit amet</p>
<p><img src="img.jpg"/></p>
<p>Lorem ipsum dolor sit amet</p>
</div>
Is it possible?
Thanks,
Lau