substring selector with jquery?

后端 未结 5 1096
南笙
南笙 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:31

    Search for the text and replace the text.

    HTML :

    Metuentes igitur idem latrones Lycaoniam magna parte campestrem

    jQuery :

    $("#findButton").click(function(){
        var inputText = $("#inputTextBox").val();
        var mainText = $("#mainText").text();
        var updatedText = "" + inputText + "";
        mainText = mainText.replace(inputText, updatedText);
        $("#mainText").html(mainText);
    });
    

    Demo

提交回复
热议问题