是否可以使用jQuery设置“for”(AssociatedControlID)属性?我正在尝试像这样将其设置为标签后出现的下一个控件:
$('label.asssociateClass').each(function()
{
var toAssociate = $(this).next(':input');
$(this).attr("for", toAssociate.attr("id"));
});
问题在于如果我不通过AssociatedControlID将其设置在服务器上,由于在这种情况下它以而不是
$(this).replaceWith(l); $(this).css({ "width": "0", "height": "0", "overflow": "hidden", "position": "absolute" }); }); });
- VictorassociateClass
类,但是你改变了我发布的选择器来查找invisibleAccess
...它不会找到任何匹配项,因为你的span拥有的内容和你更改后要查找的内容不匹配,明白吗?如果你想让new标签具有invisibleAccess
类,则交换你代码片段中这两个类出现的位置。 - Nick Craver