У меня есть этот HTML-код на моей странице:
<div class="phrase">
<ul class="items">
<li class="agap"><ul><li>TEXT1</li></ul></li>
<li class="agap"><ul> </ul></li> <!-- empty ul -->
<li class="aword">TEXT2</li>
..
</ul>
</div>
<div class="phrase"> ... </div>
Я хотел бы получить для каждой "фразы" все элементы в "элементах" в текстовой переменной, например:
var string = "TEXT1 - BLANK - TEXT2";
В настоящее время у меня есть этот код javascript:
<script>
$(function() {
$('.phrase .items').each(function(){
var myText = "";
// At this point I need to loop all li items and get the text inside
// depending on the class attribute
alert(myText);
});
};
</script>
Как я могу повторить все <li>
внутри .items
?
Я пытался разными способами, но я не получил хороших результатов.