[英]jquery set attr() input object
I have a form application. 我有一个表格申请。 I need to access an input object.
我需要访问一个输入对象。 I can not add this attribute.
我无法添加此属性。
i am getting error : 我收到错误消息:
Uncaught TypeError: Property 'children' of object # is not a function scripts.js:106 (anonymous function) scripts.js:106 x.event.dispatch jquery.js:4597 y.handle
未捕获到的TypeError:对象#的属性'children'不是函数scripts.js:106(匿名函数)scripts.js:106 x.event.dispatch jquery.js:4597 y.handle
elm[6].children() = Not null elm [6] .children()=不为空
t[0].value = Have a value. 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);
}
})
I can see input object details. 我可以看到输入对象的详细信息。 But i cannot add attribute..
但是我不能添加属性。
Use eq()
instead of brackets, as [6]
accesses the underlying dom node in the array-like jQuery object, and then you no longer have a jQuery object that can be chained with jQuery methods etc 使用
eq()
代替方括号,因为[6]
访问数组状jQuery对象中的基础dom节点,然后您不再具有可以与jQuery方法链接的jQuery对象,等等。
elm.eq(6).children().attr('id', t[0].value);
Note that the way you're doing this could potentially set the same ID to multiple elements, which is not valid. 请注意,您执行此操作的方式可能会为多个元素设置相同的ID,这是无效的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.