简体   繁体   English

当我使用javascript更改标签文本时,为什么querySelectorAll不是函数错误弹出?

[英]why querySelectorAll is not a function error pop up when i change the text of a tag using javascript?

I'm trying to change the text of a tag using javascript. 我正在尝试使用javascript更改标签的文本。

This is my HTML: 这是我的HTML:

<div class="btn_list03 btn_list">
    <a href="javascirpt:void(0);" id="btn_sort">good</a>
</div>

This is my JavaScript: 这是我的JavaScript:

document.querySelector('#btn_sort').textContent = "comment"
$('#btn_sort').text("comment");

I've tried these code. 我已经尝试过这些代码。 they change the text well but every single time i change the text i get this error querySelectorAll is not a function. 他们很好地更改了文本,但是每次我更改文本时,都会收到此错误querySelectorAll不是函数。

Error: 错误:

Uncaught TypeError: c.querySelectorAll is not a function at MutationObserver. 未捕获的TypeError:c.querySelectorAll不是MutationObserver的函数。

Should i just ignore that error or Did i make something wrong? 我应该忽略该错误还是做错了什么?

any help would be appreciate thank you. 任何帮助将不胜感激谢谢。

--edited-- -编辑-

n && c && e.MutationObserver && (o = new e.MutationObserver(function(e) {
                                for (var t = [], n = 0; n < e.length; n += 1) {
                                    var o = e[n];
                                    if ("attributes" === o.type)
                                        t.push(o.target);
                                    else if ("childList" === o.type)
                                        for (var r = o.addedNodes, i = 0; i < r.length; i += 1) {
                                            var c = r[i];
                                            t.push(c);
                                            for (var s = c.querySelectorAll("[id],[class],[href]"), a = 0; a < s.length; a += 1)
                                                t.push(s[a])
                                        }
                                }
                                l(t)
                            }

i found it this error is occurred in external js library and this is where the error is occurred. 我发现此错误发生在外部js库中,这是发生错误的地方。

It was caused from chrome's Ghostery extension not my js problem. 这是由于chrome的Ghostery扩展而不是我的js问题引起的。

when i turned it off the error was disappeared. 当我关闭它时,错误消失了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM