jQuery在Safari中不起作用 [英] Jquery not working in Safari
本文介绍了jQuery在Safari中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,有人能弄清楚为什么这在Safari中不起作用吗?其摘自Yi Jiang的代码.非常感谢
Hi could anybody work out why this would not work in Safari? its taken from code by Yi Jiang. Many Thanks
<div id="profile-list"></div>
<script>
var classes = ['email-checkout', 'absc', 'random', 'brrrr'];
for (var i = 0; i < 6000; i++) {
$('<input />').attr({
type: 'checkbox',
class: classes[Math.floor(Math.random() * classes.length)],
checked: (Math.random() > .5)
}).appendTo('#profile-list');
}
</script>
推荐答案
我看着开发者控制台,它给出了一个解析错误,指出class
是保留字.如果您将选项更改为引号,那么它会起作用:
I looked at the developer console and it gave a parse error that class
is a reserved word. If you change your options to be quoted, then it works:
for (var i = 0; i < 40; i++) {
$('<input />').attr({
"type": 'checkbox',
"class": classes[Math.floor(Math.random() * classes.length)],
"checked": (Math.random() > .5)
}).appendTo('#profile-list');
}
这篇关于jQuery在Safari中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文