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"); });
        });
    });

第一次单击后,它仅切换锚文本而不切换下拉列表和文本框.

最佳答案
.toggle()实际上是单击事件的一种便捷方法,因此在同一元素的click事件处理程序中使用.toggle()会出现问题.代替…

$(document).ready(function() {
    $('.appendvalue > td > a').live("click",function(e) {
        e.preventDefault();
        $(this).prevAll().toggle();
        if ($(this).parent().find("input").is(":hidden")) {
            $(this).text("add static value");
        } else {
            $(this).text("select from dropdown");
        }
    });
});

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: &lt;span id=&quot...
jQuery 添加水印 &lt;script src=&quot;../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...