Jquery: Select Paragraphs That Only Contain " "
Possible Duplicate: Remove elements with only a space using jQuery Wordpress does this thing with adding
when doing a line-break in the
Solution 1:
Add this to your functions.php
file if you have access to the theme files.
functionuser_content_replace($content) {
return str_replace('<p> </p>','<p class="example"> </p>',$content);
}
add_filter('the_content','user_content_replace', 99);
I made it insert a class instead of removing.
Solution 2:
This would work to select the paragraphs in question:
$("p").filter(function() {
return $.trim($(this).html()) == ' ';
});
Solution 3:
You can do something like this
$(document).ready(function(){
$("p").each(function(){
if($(this).html()==" ") {
alert($(this).attr('id'));
}
});
});
And the HTML I used was
<pid="test"class="les"> </p><pclass="les"id="test1">aaaa </p>
So it should alert only p with id test
Hope this helps
Post a Comment for "Jquery: Select Paragraphs That Only Contain " ""