You are about to change the character color of Option with two buttons.
It works normally on Edge, FF, and Chrome, but in IE, the font color does not change as soon as the button is pressed and the cursor moves out of the pressed button.
I wonder if it's not an IE bug...
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<script>
window.onload = function(){
var selectbox = document.getElementsByTagName('select')[0];
var options = selectbox.querySelectorAll('option');
document.getElementById('change').addEventListener('click', function(){
for(var i = 0; i < options.length; i++) {
options[i].style.color = 'blue';
}
});
document.getElementById('cancel').addEventListener('click', function(){
for(var i = 0; i < options.length; i++) {
options[i].style.color = 'black';
}
})
}
</script>
<body>
<select multiple>
<option>test1</option>
<option>test2</option>
</select>
<button id = "change">Change</button>
<button id = "cancel">Cancel</button>
</body>
</html>
I want to change the color of the writing when I press the Change button for IE11
Aucun commentaire:
Enregistrer un commentaire