jQuery find and replace string

前端 未结 6 951
天命终不由人
天命终不由人 2020-11-28 22:37

I have somewhere on website a specific text, let\'s say \"lollypops\", and I want to replace all the occurrences of this string with \"marshmellows\". The problem is that I

6条回答
  •  粉色の甜心
    2020-11-28 23:22

    You could do something like this:

    HTML

    Hi, I am Murtaza


    jQuery

    $(".element span").text(function(index, text) { 
        return text.replace('am', 'am not'); 
    });
    

提交回复
热议问题