I have <p>
tag and in menu
<p>日本刀日本刀日本刀日本刀</p>
but I want wrap text when text over 16 byte
Just using some simple steps: 8 is set for number of characters you want to wrap
var p = $('p'), string = p.text();
if (string.length > 8) {
var stringToWrap = string.substring(0, 8);
p.html(string.replace(stringToWrap, '<span>'+ stringToWrap +'</span>'));
}
span {
font-weight: bold;
color: red;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p>日本刀日本刀日本刀日本刀</p>
`?
– Louys Patrice Bessette Jun 05 '18 at 04:25