简体   繁体   中英

When click select tag why IE does not deselect text in input

I have a input text and a select tag in HTML. I input something in input tag and select text, but when I click select tag to select something, IE does not deselect text in input tag. Is this IE's specification? Can I use JavaScript to deselect text in input tag? 在此处输入图片说明

<input type="text" />
<br>
<select>
<option>aaaaa</option>
<option>bbbbb</option>
<option>ccccc</option>
<option>ddddd</option>
</select>

Found a solution.

window.document.onmousedown = mousedownControl;
function mousedownControl(e) {
    e = window.event;
    if (e.srcElement.nodeName == "SELECT") {
        document.selection.empty();
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM