Jquery设置attr()输入对象

jquery set attr() input object

本文关键字:输入 对象 设置 attr Jquery      更新时间:2023-09-26

我有一个表单应用程序。我需要访问一个输入对象。我不能添加这个属性。

i am getting error:

Uncaught TypeError: Property 'children' of object # is不是函数scripts.js:106(匿名函数)scripts.js:106.event.dispatch jquery.js:4597 .handle

elm[6].children() = Not null

t[0]。value =有一个值

$(".demo").delegate(".configuration .dropdown-menu button", "click", function (e) {
    e.preventDefault();
    var t = $(this).parent().children();
    var elm = t.parent().parent().parent().parent().parent().children().children();
    debugger;
    if (t[1].id == "Id") {
        elm[6].children().attr('id', t[0].value);
    }
})

我可以看到输入对象的细节。

使用eq()代替括号,因为[6]在数组式jQuery对象中访问底层dom节点,然后您不再拥有可以与jQuery方法等链接的jQuery对象

elm.eq(6).children().attr('id', t[0].value);

请注意,您这样做的方式可能会为多个元素设置相同的ID,这是无效的