1 回答

TA貢獻(xiàn)1998條經(jīng)驗(yàn) 獲得超6個(gè)贊
您可以嘗試以下簡單的邏輯來實(shí)現(xiàn) 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>
添加回答
舉報(bào)