First word selector

后端 未结 7 710
野性不改
野性不改 2020-11-29 06:04

How can I select the first word in a div?

I need to be able to insert a line break after the first word, or wrap it in a span tag. I need to do this for multiple di

7条回答
  •  情话喂你
    2020-11-29 06:37

    This may help you

    First Word in String with jquery

    $('div.message').text(function(i,txt) {
        var name = $('div.name').text().split(' ')[ 0 ];   
    });
    

提交回复
热议问题