版权声明:仅仅菜鸟,愿帮到工作中预bug困惑的您 https://blog.csdn.net/weixin_41716259/article/details/83783648
描述:通过你好来判断hello是否启用和禁止
html:
<li>
<span class="xin">*</span><label>你好</label>
<select id="dimAcc">
<option >类似</option>
<option >精确</option>
</select>
</li>
<li>
<span></span><label>hello</label>
<select class="openClose" disabled="disabled">
<option value="1">hello_one</option>
<option value="1">hello_two</option>
<option value="1">hello_three</option>
<option value="1">hello_four</option>
</select>
</li>
js:
$("#dimAcc").on("change",function () {
var Accopt = $("#dimAcc option:selected").text();
// console.log(Accopt)
if( Accopt === "类似"){
$(".openClose").attr("disabled","disabled").css("background","#eee");
// console.log(1 +"类似")
}
if(Accopt === "精确"){
$(".openClose").removeAttr("disabled").css("background","#fff");
// console.log(2 + "精确")
}
})