使用jquery将内容包装在标题中的两个div中
我想把这个转变为:使用jquery将内容包装在标题中的两个div中,jquery,Jquery,我想把这个转变为: <div class="month_date"> <div class="month_title">March, </div> <div class="month_title_year"> 2016</div> </div> 前进 2016 …使用jQuery将其转换为 <div class="month_date"> <h3>March, 201
<div class="month_date">
<div class="month_title">March, </div>
<div class="month_title_year"> 2016</div>
</div>
前进
2016
…使用jQuery将其转换为
<div class="month_date">
<h3>March, 2016</h3>
</div>
2016年3月
这是我想到的,但它将每月和每年的标题分别包装起来
jQuery('.month_date div').contents().unwrap().wrap("<h3></h3>");
jQuery('.month\u date div').contents().unwrap().wrap(“”);
您必须在此上下文中使用
jQuery('.month_date div').contents().unwrap().unwrap().wrapAll("<h3></h3>");
jQuery('.month\u date div').contents().unwrap().unwrap().wrapAll(“”);
无需任何包装或展开:
$('div.month\u date').html(函数(){
返回“”+$(this.find('div.month\u title').text()+$(this.find('div.month\u title\u year').text()+“”
})
前进
2016