innerHTML: How To Avoid

前端 未结 5 451
孤城傲影
孤城傲影 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:55

    jsFiddle Demo

    Take advantage of the tools available. You can navigate down the DOM from the element you already have stored in pItems. The first image tag, you will alter the src. This will work:

    pItems[i].getElementsByTagName("img")[0].src = kissSource;
    

提交回复
热议问题