substring selector with jquery?

后端 未结 5 1097
南笙
南笙 2021-01-23 01:02

Is it possible to select only part of a string using jquery? For example I have a text

Metuentes igitur idem latrones Lycaoniam magna parte campestrem&l

5条回答
  •  遥遥无期
    2021-01-23 01:29

    Based on the answer from here: Wrap around part of text inside an element

    you could do the following:

    $('p').html(function(index, oldHtml){
       return oldHtml.replace(/(amet)/g, '$1');
    });
    

    http://jsfiddle.net/YxMvq/

提交回复
热议问题