CSS pseudo elements in select tag options in Internet Explorer

后端 未结 2 1118
别跟我提以往
别跟我提以往 2021-01-05 08:11

I\'m trying to add some CSS ::before content to the tags of a tag can only contain:

Zero or more , and script-supporting elements.

Therefore I will probably end up using a JavaScript solution like the below.

document.getElementById("multiSelect").onchange = function() {

  var opts = this.getElementsByTagName("option");

  for (var i = 0; i < opts.length; i++) {

    if (opts[i].selected === true) {
      opts[i].innerHTML = "SELECTED: " + opts[i].value;
    } else {
      opts[i].innerHTML = "excluded: " + opts[i].value;
    }

  }
};
select {
    height: 10em;
    width: 10em;
    overflow-y: hidden;
}

提交回复
热议问题