There is a challenge with the ::-ms-expand
pseudo-element as it technically does not exist in the DOM, according to Mozilla's documentation. To address this without relying on CSS support, you can dynamically inject the desired rule into the stylesheet using JavaScript's addRule
:
$('select').css('::-ms-expand', 'none');
if (navigator.appVersion.indexOf("MSIE") !== -1 || navigator.appVersion.indexOf("Trident") !== -1) {
document.styleSheets[0].addRule('select::-ms-expand', 'display: none;');
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select>
<option>1</option>
</select>
It's important to note that adding this rule may trigger a warning in Chrome and Firefox, but it should work in Internet Explorer. Therefore, it's advisable to verify that the user is using Internet Explorer by checking for MSIE
or Trident
in their navigator.appVersion
.
I hope this explanation proves useful! :)