Replacing text with smiley image using Jquery

后端 未结 2 1665
-上瘾入骨i
-上瘾入骨i 2021-01-22 08:48

Please Guys, I am new to Jquery. I have been searching for a suitable help since last week but I can\'t find any. I want to replace a text with a smiley image using jquery but I

2条回答
  •  长情又很酷
    2021-01-22 09:21

    You can use following code:

    var a = [[':happy;',''],[':sick;',""]];
    a.forEach(function(item) {
        $('p').each(function() {
            var text = $(this).html();
            $(this).html(text.replace(item[0], item[1]));
        });
    });
    

    Working example here: Smiley codes replace

提交回复
热议问题