I'm importing a facebook RSS feed and many of the posts are missing a title. So in that case I want to pull some content from the body and use it as the title. The problem is that the body content can look like this...
Lorem ipsum<br>www.youtube.com<br>dolor sit amet.
I can't simply remove the br tags because it will become a run on sentence. I would rather replace the tags with a single space or comma with a space. I've tried the following code, but it doesn't seem to be working.
$('.teaser-title br').replaceWith(' ');
Thoughts?
2 Possible problems
teaser-title
. Anyway, this works
<div class="teaser-title">
Lorem ipsum<br>www.youtube.com<br>dolor sit amet.
</div>
<script>
$(function() {
$('.teaser-title br').replaceWith(' ');
});
</script>
Posting because it can be done! Could use CSS :P
(only works in webkit, so not really recommended)
.teaser-title br{
content:"";
}
.teaser-title br:after{
content:" ";
}
Live Demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With