【问题标题】:Change from text box appearance to label appeareance according to the focus根据焦点从文本框外观更改为标签外观
【发布时间】:2011-10-08 09:49:15
【问题描述】:

我的gridview 中有一个模板字段,这个模板字段是一个(文本框)。我想做的是:在用户完成写作并移动到下一个文本框后,失去焦点的文本框变成标签或类似标签,如果再次获得焦点,则变成文本框.and ...等

如何做这样的事情?

【问题讨论】:

    标签: jquery asp.net css gridview templatefield


    【解决方案1】:

    像这样:

    <script type="text/javascript">
    function show(){
    document.getElementById("input1-label").style.display = "none";
    document.getElementById("input1").style.display = "block";
    document.getElementById("input1").focus();
    }
    
    function hide(){
    if(document.getElementById("input1").value != "") document.getElementById("input1-label").innerHTML = document.getElementById("input1").value;
    document.getElementById("input1-label").style.display = "block";
    document.getElementById("input1").style.display = "none";
    }
    </script>
    
    <label id="input1-label" onclick="show()" style="display:none">Label</label>
    <input type="text" id="input1" onblur="hide()" />
    

    http://jsfiddle.net/9v4TJ/1/

    【讨论】:

      【解决方案2】:

      您搜索内联编辑。

      这是一个你可以使用的 jQuery 内联编辑,但你可以在 google 上找到更多。

      http://yelotofu.com/2009/08/jquery-inline-edit-tutorial/

      还有现场演示

      http://yelotofu.com/labs/jquery/snippets/inlineEdit/demo_final.html

      您需要彻底改变更新数据库的方式。

      【讨论】:

        猜你喜欢
        • 2013-01-31
        • 2017-07-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-10-28
        • 1970-01-01
        相关资源
        最近更新 更多