jQuery)SyntaxError:缺少:在属性id之后)

jQuery ) SyntaxError: missing : after property id)

本文关键字:id 之后 属性 缺少 SyntaxError jQuery      更新时间:2023-09-26

我的页面中有一些jQuery不断给出错误:

SyntaxError: missing : after property id

代码

        <div id='content1'  >
<script type="text/javascript">
    $(document).ready(function () {
        var theme = getDemoTheme();
        var source = [
            "Suppliers",
            "Global Networks",
            "Supplier Networks",
            "Supplier Prices",
            "Supplier Data Import",
            "Supplier Target Price Export"
        ];
        // Create a jqxDropDownList
        $("#jqxWidget1").jqxDropDownList({ source: source, selectedIndex: 0, width: '200',margin-top:'0px', height: '25', theme: theme });
    });
</script>
<div id='jqxWidget1'>
</div>

Firebug说它在这条线上:

在传递给jqxDropDownList的json选项中,您有一个密钥margin-top,因为它有一个-,所以必须包装在""

尝试

$("#jqxWidget1").jqxDropDownList({ source: source, selectedIndex: 0, width: '200',"margin-top":'0px', height: '25', theme: theme });