3
我堅持這個任何人都可以幫助我的現場活動......切換問題jQuery中
下面是HTML
<tr class="appendvalue">
<td colspan="2">
<asp:DropDownList ID="ddlSource" runat="server"></asp:DropDownList>
<asp:TextBox ID="txtSourceValue" runat="server" CssClass="hide" />
<a href="#" class="t12">add static value</a>
</td>
這裏是jQuery的
$(document).ready(function() {
$('.appendvalue > td > a').live("click", function(e) {
e.preventDefault();
$(this).prev().prev().toggle();
$(this).prev().toggle();
$(this).toggle(function() { $(this).text("select from dropdown"); }, function() { $(this).text("add static value"); });
});
});
第一次點擊後,只切換'錨點文本不切換下拉菜單和文本框..
如果您打算使用$(this)多於一次緩存它。 var $ this = $(this)。然後使用$ this剩下的地方,意味着你不重新創建jQuery對象。 – PetersenDidIt 2010-01-30 15:42:09
@petersendidit已經很晚了。我聲稱豁免。 :)良好的捕獲,不知道爲什麼我沒有看到,當我編碼它。它已被修復。謝了哥們! – 2010-01-30 21:22:55