I need help implementing a read more feature in jquery that will allow me to cut off content and reveal the remainder with the click of a button.
If the content is simple text, I could easily wrap the hidden portion in a span. However, the content may contain HTML as well.
For instance:
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea --CUT OFF HERE-- commodo consequat. Duis aute irure dolor in reprehenderit</p>
<p> voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
In this example, I want to cut off the content at the marker "--CUT OFF HERE--" within the first paragraph. The marker may not always be inside a paragraph tag or there may not be any other HTML elements present. I need a solution that can handle these variations.
What would be the best way to achieve this functionality using jQuery?