根据select中的option选项的值不同,响应不同的事件
一个可以用value方法
另一个可以用selectIndex,selecteIndex属性可以设置或者返回下拉列表中被选选型的索引号(若允许多重选择,则仅会返回第一个被选选项的索引号)。
<select id="relationship" name="" onchange="gradeChange()">
<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业务代码):');
}
}