小编12M*_*2Mb的帖子

MS Edge 中的 :scope 伪选择器

每当我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)

我要再次指出,它适用于除 …

javascript selectors-api microsoft-edge

1
推荐指数
1
解决办法
988
查看次数

标签 统计

javascript ×1

microsoft-edge ×1

selectors-api ×1