It's unclear what exactly you're aiming to accomplish, but I may have a solution. In a previous project of mine, I encountered a similar scenario where I needed to extract text from input boxes. My suggestion is to assign unique IDs to each paragraph, line, or input box and then attach an event to the div containing these elements. By doing so, you'll have the freedom to execute various actions.
For instance:
You don't necessarily need to target the body element; you can simply apply the event listener to your specific div.
document.body.addEventListener("foo_event", get_target, false);
<p id="someid">Insert interesting content here—this could be text, an input field, or anything else.
Assign IDs to all lines for easy referencing and consider adding classes for styling purposes.</p>
function get_target(e){
//Something has triggered the event, let's respond accordingly
if ("someid" === e.target.id ) {
//Execute code specific to this paragraph or element
/* Ideally, it's best practice to implement an algorithm for ID testing rather than relying on multiple if statements */
}
}