如何在jquery中检查标签是否为null [英] how to check the label is null in jquery

查看:103
本文介绍了如何在jquery中检查标签是否为null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里我有一个标签,其中表格字段值中的watever我将它存储在标签中,它有编辑选项,点击编辑文本框将来到哪里,如果我想编辑我可以.......并且有为它写了一个jquery。







jquery:



$(document).ready(function(){

$(#EditNumber)。click(function(){

$( .MobileNumber)。切换(盲);

$(#TxtMobile)。val($(#LblMobileNumer)。text());





});



$(#CancelEditNumber)。click(function(){

$(。MobileNumber)。切换(盲);

$(#TxtMobile)。val();

});

});



here i have a label wherein watever there in table field values i am storing it in label where it has optio of editing where click edit textbox will come where if i want to edit i can.......and have written a jquery for it.



jquery:

$(document).ready(function () {
$("#EditNumber").click(function () {
$(".MobileNumber").toggle("blind");
$("#TxtMobile").val($("#LblMobileNumer").text());


});

$("#CancelEditNumber").click(function () {
$(".MobileNumber").toggle("blind");
$("#TxtMobile").val("");
});
});

<div style="margin: 10px">
                               <label>MobileNumber:</label>
                               <asp:Label ClientIDMode="Static" class="MobileNumber" ID="LblMobileNumer" runat="server"></asp:Label>
                               <asp:TextBox ID="TxtMobile" ClientIDMode="Static" class="MobileNumber" Style="display: none;" runat="server"></asp:TextBox></td>
                   <a href="#" class="MobileNumber" id="EditNumber">Edit</a></span>&nbsp;<span>
                       <a href="#" class="MobileNumber" id="CancelEditNumber" style="display: none;">Cancel</a></span>
                           </div>







这个上面的功能在数据库中已经存在,如果我有价值...我的问题是在pageload标签上一旦页面加载文本框,我就必须插入值应该可见......进入我改变了下面的jquery





jquery






this above function works when already in the database if i have value...my problem is on pageload label will be empty and i have to insert values , once the pageloads the textbox should be visible......to enter for the i altered the jquery like below


jquery

$(document).ready(function () {
         if ($("LblMobileNumer") == null) {
             $("#TxtMobile").show();
         }
         else {
             $("#EditNumber").click(function () {
                 $(".MobileNumber").toggle("blind");
                 $("#TxtMobile").val($("#LblMobileNumer").text());


             });

             $("#CancelEditNumber").click(function () {
                 $(".MobileNumber").toggle("blind");
                 $("#TxtMobile").val("");
             });
         }
     });









在写完这段代码之后我面临的问题就是如果label也不是null也会显示文本框?请尽快给我一个解决方案: - (





here after writing this code i am facing problems like if label is not null also the textbox is shown?pls give me a solution for this soon:-(

推荐答案

(文件).ready(function(){
(document).ready(function () {


(#EditNumber)。click(function(){
("#EditNumber").click(function () {


(。MobileNumber)。toggle(blind);
(".MobileNumber").toggle("blind");


这篇关于如何在jquery中检查标签是否为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆