Replace multiple strings with multiple other strings

前端 未结 18 2284
别那么骄傲
别那么骄傲 2020-11-22 04:14

I\'m trying to replace multiple words in a string with multiple other words. The string is \"I have a cat, a dog, and a goat.\"

However, this does not produce \"I ha

18条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-22 04:58

    Solution with Jquery (first include this file): Replace multiple strings with multiple other strings:

    var replacetext = {
        "abc": "123",
        "def": "456"
        "ghi": "789"
    };
    
    $.each(replacetext, function(txtorig, txtnew) {
        $(".eng-to-urd").each(function() {
            $(this).text($(this).text().replace(txtorig, txtnew));
        });
    });
    

提交回复
热议问题