语法错误:使用jQuery的意外字符串

时间:2014-10-02 14:02:47

标签: jquery object syntax

我试图遍历对象,以便输出键和值,但我不断收到意外的字符串错误。有人可以帮忙吗?

var obj = {
    'a.video-0': "<span>Benefits of USF\'s Online Master\'s Degree Program in Management Information Systems</span>" 
    'a.video-1': "<span>How are the courses optimally designed</span>"
};

for( key in obj ) {
    jQuery( [key] ).html(obj[key]);
});

1 个答案:

答案 0 :(得分:0)

您错过了&#34;,&#34;,并且您有导致其他错误。

试一试:

var obj = {
    'a.video-0': "<span>Benefits of USF\'s Online Master\'s Degree Program in Management Information Systems</span>",
    'a.video-1': "<span>How are the courses optimally designed</span>"
};

for( key in obj ) {
    jQuery(key).html(obj[key]);
};

问候。