samedi 28 mai 2016

Find text in element that is NOT wrapped in html tags and wrap it with

<div class="menu-content">
  <h3>Lorem Ipsum</h3>
  TEXT THAT NEEDS TO BE WRAPPED
  <ul>
    <li>List Item 1</li>
  </ul>
</div>

I got the code above (it gets generated automatically so I can't manually wrap the text), I need to filter through the content of ".menu-content" and find the text that is not wrapped in a html tags and then wrap that text in a p tag.

I tried the following jQuery code:

$('.menu-content').find(':not(h3, ul)').wrap('<p></p>');




Aucun commentaire:

Enregistrer un commentaire