Replace word in

in

using jquery

前端 未结 8 1857
无人及你
无人及你 2021-01-18 11:54

I have a document with the following structure:

This is some text.

8条回答
  •  难免孤独
    2021-01-18 12:53

    Read http://api.jquery.com/text/#text-functionindex--text

    $("#notice p").text(function (_, ctx) {
        return ctx.replace("some", "My");
    });
    

    or

    $("#notice p").text($("#notice p").text().replace("some", "My"));
    

    or

    var  p_tag = $("#notice p");
    p_tag.text(p_tag.text().replace("some", "My"));
    

提交回复
热议问题