设置剑道下拉跨度ID

时间:2013-09-10 07:06:39

标签: kendo-ui html-select

我想设置差异。剑道ID下拉父<span>
这里是两个d-d的简单代码

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <link href="kendo/styles/kendo.common.min.css" rel="stylesheet" />
    <link href="kendo/styles/kendo.default.min.css" rel="stylesheet" />
    <script src="kendo/js/jquery.min.js"></script>
    <script src="kendo/js/kendo.web.min.js"></script>
</head>
<body>
            <input id="dropdownlist" />
            <input id="newdropdownlist" />
            <script>
                $("#dropdownlist").kendoDropDownList({
                  dataSource: [
                    { id: 1, name: "Apples" },
                    { id: 2, name: "Oranges" }
                  ],
                  dataTextField: "name",
                  dataValueField: "id",
                  index: 1
                });

                $("#newdropdownlist1").kendoDropDownList({
                  dataSource: [
                    { id: 1, name: "Apples" },
                    { id: 2, name: "Oranges" }
                  ],
                  dataTextField: "name",
                  dataValueField: "id",
                  index: 1
                });
            </script>
</body>
</html>

如何设置两个下拉跨度的不同ID可以帮助我解决这个问题 感谢。

1 个答案:

答案 0 :(得分:1)

您可以使用jQuery .closest()函数向上移动DOM树并查找父级。

$("#newdropdownlist1") // target the original input element
    .closest(".k-dropdown") // move up the DOM to the dropdown span
    .attr("id", "theNewId"); // change the id attribute