繁体   English   中英

使用 jquery 清除单选按钮更改事件中的 label 文本

[英]Clear label text in Radiobutton Change event using jquery

我无法清除单选按钮检查更改事件中的 label 文本。 lblerror is the Label it will display the error message.i handle the error message in server side but When i toggle between Excel, CSV, Tab or Custom the label should get cleared. 截至目前 label (lblerror) 文本未清除。 这是我使用的代码:

             function radioValueChanged(radioName) 
             {
                 radioValue = $(this).val();

                 if ($(this).is(":checked") && radioValue == "Excel") 
                  {
                     $('#lblError').text("");
                     $('#txtCustom').hide();                      
                     $('#divcbxSheet').show();
                     $('#lblSheetName').show();
                     $('#radcbxSheetNames').show();

                 }
                  if ($(this).is(":checked") && radioValue == "CSV") 
                 {
                     $('#lblError').text("");

                     $('#txtCustom').hide();
                     $('#lblSheetName').hide()
                     $('#radcbxSheetNames').hide();
                     $('#divcbxSheet').hide();
                 }
                  if ($(this).is(":checked") && radioValue == "Tab") 
                 {
                     $('#lblError').text("");

                     $('#txtCustom').hide();
                     $('#divcbxSheet').hide();
                     $('#lblSheetName').hide();
                     $('#radcbxSheetNames').hide();
                 }
                 if ($(this).is(":checked") && radioValue == "Custom") {
                     $('#lblError').text("");
                     $('#txtCustom').show();
                     $('#divcbxSheet').hide();
                     $('#lblSheetName').hide();
                     $('#radcbxSheetNames').hide();
                 }
             }

确保大小写匹配。 $('#lblError')不会匹配<label id="lblerror"/>

看起来您错误地使用了“this”。 您正在将参数“radioName”传递给 function 但它从未被使用过。 您是否应该使用它来获取单选按钮元素而不是“this”。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM