每当我querySelectorAll在 Microsoft Edge 中使用:scope伪选择器时,控制台中都会出现此错误
SCRIPT5022: SCRIPT5022:语法错误
我想知道是否有替代方案querySelectorAll,我在其中使用此参数::scope > * > table。我不想为此使用 jQuery。谢谢。
我还想补充一下querySelector它本身就有效
好的,这是代码示例:
function pJSON(panel) {
var json = {tables: [], images: [], text: ""};
var tables = Array.from(panel.querySelectorAll(":scope > * > table"));
var images = Array.from(panel.querySelectorAll(":scope > * > img"));
var text = panel.querySelector(":scope > textarea");
tables.forEach(table => {
json["tables"].push(tJSON(table));
});
images.forEach(image => {
json["images"].push(image.outerHTML);
});
if (text) {
json["text"] = text.value;
}
return json;
}
Run Code Online (Sandbox Code Playgroud)
我要再次指出,它适用于除 …