jquery find and replace text, without element id

前端 未结 5 1727
鱼传尺愫
鱼传尺愫 2020-12-05 20:06

I\'m playing around with finding and replacing text.

The only problem I\'m having is finding a text string, that is not attached to an element with an ID. Otherwise

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-05 20:49

    $("*").contents().each(function() {
        if(this.nodeType == 3)
            this.nodeValue = this.nodeValue.replace("old", "new");
    });
    

提交回复
热议问题