什么是管理这种情况的最好办法:内的每个变化()()jQuery的
$('.element').each(function() {
$sibling = // find a sibling to $this.
$mainElement = $(this); // memorize $(this)
$sibling.change(function() {
// when sibling changes
// do something using $mainElement
// problem is, $mainElement is not the element you think
// $mainElement is the last .element found....
})
});
一个解决方案是一个表......但后来就没有优势的变化()被嵌套在各()...
我的HTML例子:
<div id="first">
<span class="element"></span>
<input name="first" type="text" />
</div>
<div id="second">
<span class="element"></span>
<input name="second" type="text" />
</div>
在本例,$sibling = $(this).next('input');
例如。
您是否尝试过的:var $ =兄弟//找到兄弟姐妹到$这。 var $ mainElement = $(this); – luckystars 2013-02-16 12:11:31
发表html,很抱歉等待。 – Lyth 2013-02-16 15:31:26