innerHTML: How To Avoid

前端 未结 5 449
孤城傲影
孤城傲影 2021-01-02 16:00

I\'m writing a plugin which will convert emoticons to images in a text block for a particular site. The easy answer is to use regular expressions to detect the trigger text

5条回答
  •  独厮守ぢ
    2021-01-02 16:47

    If I understand you correctly, you want to convert say ":)" to an emoticon. To do that, you need to parse the text and replace those characters with an img element. So you want to do something like:

    
    
    

    here is a smily:) and another two:):)

    The above needs to be modified to deal with multiple different emoticons in each text node, but I think you get the idea.

提交回复
热议问题