1 回答
TA贡献1998条经验 获得超6个赞
您可以尝试以下简单的逻辑来实现 html 包装
jQuery(function(){
jQuery('.elementor-drop-cap-yes p').each(function(){
var $div = jQuery('<div/>');
var $children = $(this).children();
$div.append($children);
var text = jQuery(this).text();
if(text.indexOf('/')>=0) {
var index = text.indexOf('/');
//console.log(index);
var textParts = text.substring(0, index);
var newHTML = '<div class="c"><b class="d">' + text.substring(0, index) +'</b>' + text.substring(index, text.length) + '</div>';
jQuery(this).empty().append($children).append(newHTML);
}
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="elementor-drop-cap-yes">
<p>
<span class="a">
<span class="b">1</span>
</span>
0/10
</p>
</div>
添加回答
举报