根据select中的option选项的值不同,响应不同的事件

一个可以用value方法

另一个可以用selectIndex,selecteIndex属性可以设置或者返回下拉列表中被选选型的索引号(若允许多重选择,则仅会返回第一个被选选项的索引号)。

<select >
             <option value="依赖">依赖</option>
               <option value="互斥">互斥</option>
  </select> 

   function gradeChange(){
        var relationship = document.getElementById("relationship");
        var index = relationship.selectedIndex
        if (index === 0){
            $('.reason').text('依赖原因:');
            $('.reasonCode').text('与之依赖的产品代码(BOOSS业务代码):');
        } else{
            $('.reason').text('互斥原因:');
            $('.reasonCode').text('与之互斥的产品代码(BOOSS业务代码):');
        }
    }

 

相关文章:

  • 2021-10-16
  • 2021-05-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-02-16
  • 2021-09-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-08
相关资源
相似解决方案