Replacing text with smiley image using Jquery

后端 未结 2 1692
-上瘾入骨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:28

    It is actually quite simple. You only need one line to find and replace string instances in the HTML: $("body").html($("body").html().replace(/:happy;/g,'

    '));

    This sets $("body").html() to the $("body").html() with :happy; replaced with

    .

    /:happy;/g is RegEx to find the string :happy; globally (g)

    https://jsfiddle.net/heowqt1u/2/

提交回复
热议问题