1

我有问题,我有这个 html 代码

<div class="f300_sl">
   <select name="situacao_laboral" class="validate['required'] f300_sl2" onchange="alteraVencimento(this);">
<option> </option>
<option>Conta Própria</option>
<option>Prazo</option>
<option>Quadros</option>
<option>Outra</option>
  </select></div>

我的变更事件如下

    function alteraVencimento(estado){
        if(estado.value= (should be ==) 'Conta Própria'){
            document.getElementById('vencimento').innerHTML = 'Volume de Negócio:';
        }
        else{
            document.getElementById('vencimento').innerHTML = 'Vencimento:';
        }
    }

选择按钮不起作用,它总是将值放在“Conta Própria”上

编辑:没关系,= 而不是 ==

对不起。

4

1 回答 1

0

您正在分配值而不是比较它,请尝试:

function alteraVencimento(estado){
    if(estado.value == 'Conta Própria'){
        document.getElementById('vencimento').innerHTML = 'Volume de Negócio:';
    }
    else{
        document.getElementById('vencimento').innerHTML = 'Vencimento:';
    }
}

注意==而不是=.

=分配一个变量

==比较

于 2013-03-02T13:59:11.737 回答