有没有办法为下拉列表中的选定行着色?也欢迎jQuery / JavaScript

最佳答案

var select = document.getElementById("mySelectBox");
var oldSelectedIndex = select.selectedIndex;
select.addEventListener("change", function(){
    select.options[oldSelectedIndex].style.cssText = "";//or .className = ""
    select.options[oldSelectedIndex=select.selectedIndex].style.cssText = "color:red;";
}, true);

关于javascript - 下拉列表中的彩色选定行,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7398915/

10-09 23:56