gpt4 book ai didi

javascript - 在 jQuery 中创建具有属性的 HTML 元素,在 ie7 和 ie8 中失败

转载 作者:行者123 更新时间:2023-11-30 10:42:42 26 4
gpt4 key购买 nike

我正在通过 jQuery 生成一个带有属性的 HTML 元素,然后将其插入到 DOM 中。我将一个类属性传递给元素。见下文:

jQuery('<li></li>', {  
class: "myClass"
});

我在 ie7 和 ie8 中收到以下错误,位于 class: "myCLass" 行。

SCRIPT1028: Expected identifier, string or number

它适用于 ie9 和 Firefox。没有测试过任何其他浏览器。

这种生成带有属性的元素的方法在ie7和ie8中是不支持的吗?还是我的脚本有误?

最佳答案

保留。使用 className 或用引号括起来。

关于javascript - 在 jQuery 中创建具有属性的 HTML 元素,在 ie7 和 ie8 中失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10232595/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com