What is Join() in jQuery?

后端 未结 6 1390
无人及你
无人及你 2020-12-08 18:14

What is Join() in jquery? for example:

var newText = $(\"p\").text().split(\" \").join(\" \"); 
6条回答
  •  盖世英雄少女心
    2020-12-08 19:01

    You would probably use your example like this

    var newText = "" + $("p").text().split(" ").join(" ") + "";
    

    This will put span tags around all the words in you paragraphs, turning

    Test is a demo.

    into

    Test is a demo.

    I do not know what the practical use of this could be.

提交回复
热议问题