특정 문자 수만큼 텍스트에 두 번째 이상의 점이 일치하면 요소를 배치하려고합니다. 예 :jquery에서 일치하는 문자 뒤에 요소를 추가하려면 어떻게해야합니까?
<div id="mytext">
This is just a example. I need to find a solution. I will appreciate any help. Thank you.
</div>
<script>
var chars = 55;
if ($('#mytext').text().length > chars){
//add <br> after first dot found after number of chars specified.
}
</script>
... 출력은 다음과 같습니다
This is just a example. I need to find a solution. I will appreciate any help.<br>
Thank you.
이렇게하지 마십시오. CSS를 사용하여 컨테이너의 너비를 정의하십시오. – user2182349
예, 알고 있습니다. 하지만이 jquery 사용해야합니다 ..
그냥 예입니다. divs 및 다른 요소 같은 다른 요소를 배치 할 것이다. –