首页 > 解决方案 > 关于如何禁用文本字段而不影响其他人的 Jquery 单选按钮

问题描述

我需要帮助。我在 jquery 中有一个问题,当您单击单选按钮时,它不应该受到其他人的影响。

这是我的代码:

<script>
    jQuery("input[type='radio']").change(function(){
        if(jQuery(this).val() == "Not Vote Anyone")
        {
            jQuery( ".txtfield" ).prop( "disabled", false );
        } else {
            jQuery( ".txtfield" ).prop( "disabled", true );
        }
    });
</script>

网站:

http://devsrver.com/

标签: javascriptjquerywordpresscontact-form-7

解决方案


如果您使用选择器input[type='radio'],它将影响所有单选按钮。你可以这样尝试:

<script>
    jQuery("input[name='radio-743']").change(function(){
       if(jQuery(this).val() == "Not Vote Anyone"){
          jQuery( ".txtfield" ).prop( "disabled", false );
       } else {
          jQuery( ".txtfield" ).prop( "disabled", true );
       }
    });
</script>

推荐阅读