First Word in String with jquery

前端 未结 4 1319
挽巷
挽巷 2020-12-06 12:31

I\'m trying to figure out function that will help me wrap first word in string into span.

But unfortunately no luck.

Can anyone help me please?

Many

4条回答
  •  没有蜡笔的小新
    2020-12-06 13:00

    You ask how to do that in jQuery. I think you'll need a regular expression to litteraly add the span.

    Here is an example using jQuery to get a text from the DOM and make the update in the DOM after having added the span to the string with a regular expression.

    This is the text

    This is what you'll get:

    This is the text

提交回复
热议问题