I have an element with text like so:
<div class="element">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
I want to target the second sentence in this text, Usually it would ends with . ? ! or line break.
function add_br(){
//Assigning the element to a variable
var element = document.getElementsByClassName('element')[0];
//Find the 2nd sentence.
..
//Add <br> after it
..
}
So how to target the 2nd sentence and add <br> after it?
Here is an example, Let's assume this is the text:
<div class="element">
This is the first sentence. This is the second sentence! Is this the 3rd sentence? ..
</div>
The final result should be:
<div class="element">
This is the first sentence. This is the second sentence! <br> Is this the 3rd sentence? ..
</div>
` after the second sentence in this text – User1804 Aug 10 '19 at 23:02