input获得select的内容并显示在输入框中(可以选中单个值)

html: 

 <input type="text" id="expertIdt" name="expertIdt" maxlength="11" class="form-control  acvs-v-notnull" onchange="setRuleContent1()" />
 <select multiple="multiple" id="expertId" name="expertId" maxlength="11" class="form-control  acvs-v-notnull" onchange="setRuleContent()"></select>


js:

$('#expertId option').on('click', function() {
                document.getElementById('expertIdt').value=  
                document.getElementById('expertId').options[document.getElementById('expertId').selectedIndex].value;

})


效果:



猜你喜欢

转载自blog.csdn.net/sky_lq/article/details/80242316