У меня есть руководство, где каждая глава расположена в отдельном LI UL. Я пытаюсь использовать функцию jQuery Clone для поиска в родительском UL, который содержит все эти «главы» LI, и вернуть те главы, которые содержат определенный текст.
Прямо сейчас, я получаю странные результаты, вероятно, потому, что он копирует элементы на их наименьшем дочернем элементе, а не просто на весь div.
Кроме того, каждый из этих LI главы должен быть возвращен только один раз.
- makeIntoSldieshowUL - UL, содержащий все «главы»
- slideShowSlide - имя класса для каждой «главы»
- searchResultsArea - Div, в который добавляются «главы», содержащие текст
Пока у меня есть:
$("#makeIntoSlideshowUL").find(".slideShowSlide:contains('" + $(this).val() + "')").clone().appendTo("#searchResultsArea");
Чтобы дать вам представление о содержимом, которое я собираюсь клонировать, вот краткий пример
<ul id="makeIntoSlideshowUL">
<li class="slideShowSlide" id="0">
<div class="topicTitle">Cardholder responsibilities</div>
<p>Cardholders are responsible for ensuring proper use of the card. If your division or department has approved you for a Pro-Card, you must use the card responsibly in accordance with the following requirements:</p>
<ul>
<li>Purchase items for UCSC business use only</li>
<li>Never lend or share your Pro-Card</li>
<li>Purchase only allowable goods and services</li>
</ul>
</li>
<li class="slideShowSlide" id="1">
<div class="topicTitle"><strong>Restricted and Unallowable Pro-Card Purchases</strong></div>
<p>Some types of purchases are restricted are not allowed with the Pro-Card. Disputes with suppliers are initially handled by the Cardholder if, for example, they don't recognize a transaction on their statement, or the amount doesn't match their receipt. The Cardholder is responsible for contacting the supplier immediately to try to resolve the matter.</p>
</li>