문제

I want to disable/remove/not display the ::ms-clear button that is appearing in input fields in IE. How can I do the following

input[type=text]::-ms-clear { display: none; }

using JavaScript? It is sufficient for me to do this on each HTMLInputElement if that is easier.

(I wish not to use any external libraries such as jQuery)

도움이 되었습니까?

해결책

It seems that pseudo-elements are readonly? I am trying to do

window.getComputedStyle(this.inputTextElement, "::ms-clear").setProperty("display", "none");

but I get exception NoModificationAllowedError.

The closest working thing to set this in JavaScript seems to be doing

var style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = '::-ms-clear{display:none};';
document.getElementsByTagName('head')[0].appendChild(style);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top