JSFiddle - React, Tailwind, and code Playground
HTML
<select id="test">
<option value="">请选择</option>
<option value="1">选项一</option>
<option value="2">选项二</option>
</select>
<input type="checkbox" id="flag" value="1"
onchange="change(this, 'test')"/>
<p id="show">xx</p>
JavaScript
function change(self, targetId) {
if ($(self).is(':checked')) {
$("#" + targetId).val("44");
$("#" + targetId).attr("disabled", true);
}
else {
$("#" + targetId).attr("disabled", false);
}
$("#show").html($("#" + targetId).val());
}