I'm building a Wordpress site and wrote some code that takes overflow text from one <div>
to another. I want my clients to be able to insert the break from the .featured div
to the .overflow div
on their own using Wordpress' "Read More" insert.
This just adds a comment that says <!--more-->
into the p
element. See example:
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
<!--more-->
Ut enim ad minim veniam, <span>quis nostrud exercitation</span> ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in 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>
What I want to do is use jQuery to select all the text before and after the <!--more-->
, then I can store them in two variables and move them around where I need them.
Note: any inline HTML tags (strong
,em
,a
,span
, etc) need to be saved in those variable as well.
I've been messing around with $('p').text().split('<!--more-->');
, but there's still something I'm missing.
Thanks.