jquery - 如何将一组元素中的 DIV 文本传递到另一组元素?

问题描述 投票:0回答:1
html jquery each
1个回答
0
投票

您将获取所有 h3 标签内容,并每次在所有“阅读更多”位置应用所有内容。一种方法是获取每个帖子的 div,然后获取 h3 标签并应用在“阅读更多”中,例如:

var postDiv = jQuery('.post-div'); 

postDiv.each(function () {
  let content = jQuery(this).first('h3').text();

  jQuery(this).first(".eael-post-elements-readmore-btn")
   .append( "<p class='someclass'>" + content + "</p>"  );
});

这是ideia,请检查代码。

© www.soinside.com 2019 - 2024. All rights reserved.