Javascript jQuery内容分离
我的结构如下:Javascript jQuery内容分离,javascript,jquery,Javascript,Jquery,我的结构如下: <div class="cardapio-content"> <h5>Tittle of tab 1</h5> <p>Content of tab 1</p> <h5>Tittle of tab 2</h5> <p>Content of tab 2</p> <h5>Tittle of tab 3</h5>
<div class="cardapio-content">
<h5>Tittle of tab 1</h5>
<p>Content of tab 1</p>
<h5>Tittle of tab 2</h5>
<p>Content of tab 2</p>
<h5>Tittle of tab 3</h5>
<p>Content of tab 3</p>
</div>
谢谢。使用jQuery的.eq来获取所需的元素
jQuery('.cardapio-content h5').each(function(k, v) {
alert(jQuery('.cardapio-content p').eq(k).html());
})
使用jQuery的.eq获取所需的元素
jQuery('.cardapio-content h5').each(function(k, v) {
alert(jQuery('.cardapio-content p').eq(k).html());
})
只需使用。下一步:
只需使用。下一步:
仅用于每个函数和选择器,将它们包装在一起:
$('.cardapio-content h5').each(function(){
$(this).next('p').andSelf().wrapAll('<div class="cardapio-menu" />');
});
仅用于每个函数和选择器,将它们包装在一起:
$('.cardapio-content h5').each(function(){
$(this).next('p').andSelf().wrapAll('<div class="cardapio-menu" />');
});
请同时显示预期输出-我无法从您的文字描述中看出。请同时显示预期输出-我无法从您的文字描述中看出。您可以这样做。下一个“p”确保它是。每天学习新内容:-您可以这样做。下一个“p”确保它是。每天学习新内容:-