lim*_*lus 2 jquery jquery-ui parent
我想使用jQuery UI的位置实用程序来将多个元素集中在它们各自的父元素中.这是我想出的:
$(".elementclass").position({
"my": "center center",
"at": "center center",
"of": $(this).parent()
});
Run Code Online (Sandbox Code Playgroud)
不幸的是,这不起作用,因为jQuery对象$(this)在某种程度上不引用此上下文中的定位元素.我该如何解决这个问题?
这个怎么样:
$(".elementclass").each(function(i)
{
$(this).position({
"my": "center center",
"at": "center center",
"of": $(this).parent()
});
});
Run Code Online (Sandbox Code Playgroud)