Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如果选择了其他表单,是否可以使用jquery清除文本表单?_Jquery - Fatal编程技术网

如果选择了其他表单,是否可以使用jquery清除文本表单?

如果选择了其他表单,是否可以使用jquery清除文本表单?,jquery,Jquery,下面的jquery代码根据所选的国家/地区,使用状态输入文本框切换状态下拉列表 它也会根据您选择的一个来禁用另一个,但是我希望它不会禁用另一个表单字段,而是在选择“usstate”时清除“othstate”输入框的内容 这可能吗 <script> function locationlist() { $('#othstate').hide().attr("disabled", "disabled"); $('#country').change(function ()

下面的jquery代码根据所选的国家/地区,使用状态输入文本框切换状态下拉列表

它也会根据您选择的一个来禁用另一个,但是我希望它不会禁用另一个表单字段,而是在选择“usstate”时清除“othstate”输入框的内容

这可能吗

<script>

function locationlist() {
    $('#othstate').hide().attr("disabled", "disabled");
    $('#country').change(function () {
        var val = $(this).val();
        if (val == 224) {
            $('#usstate').val('').show().removeAttr("disabled");
            $('#othstate').hide().attr("disabled", "disabled");
        } else {
            $('#usstate').val('').hide().attr("disabled", "disabled");
            $('#othstate').show().removeAttr("disabled");
        }
    });
}

</script>

函数位置列表(){
$('#othstate').hide().attr(“禁用”、“禁用”);
$('#country')。更改(函数(){
var val=$(this.val();
如果(val==224){
$('#usstate').val('').show().removeAttr(“禁用”);
$('#othstate').hide().attr(“禁用”、“禁用”);
}否则{
$('#usstate').val('').hide().attr(“禁用”、“禁用”);
$('#othstate').show().removeAttr(“禁用”);
}
});
}

这将清除以下状态的内容:

$('#othstate').val('');

谢谢,我知道这是正确的,因为我在代码的另一部分看到了它,但它不适合我,古怪的问题。您是否尝试修改代码以使行:$('#othstate').hide().attr(“disabled”,“disabled”);变成$('#othstate').val(''.hide().attr(“已禁用”、“已禁用”)?