I need to know if parent exist then I need to do this else this. Here is the code:
if ($('#block-slides p a img.alignleft').parent().length) {
$(this).parent().parent().css({'max-width' : '100%', 'padding' : '0'}).addClass('clearfix');
} else {
$('#block-slides p img.alignleft').parent().css({'max-width' : '100%', 'padding' : '0'}).addClass('clearfix');
}
But nothing happen. Any help please?
…if you’re just looking for the
<p>-element, try:http://api.jquery.com/closest/