最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Disable IE 11 input clear 'X' button - Stack Overflow

programmeradmin0浏览0评论

I know this will be marked as a duplicate but every suggested CSS fix out there is not working for me in IE 11.

I am trying to disable an input clear 'X' in IE 11.

Among numerous others I have tried:

input::-ms-clear {
    display: none;
    height: 0;
    width: 0;
}

or, if anyone can tell me how to get that to work that would also be acceptable, but I would rather have it gone altogether.

I know this will be marked as a duplicate but every suggested CSS fix out there is not working for me in IE 11.

I am trying to disable an input clear 'X' in IE 11.

Among numerous others I have tried:

input::-ms-clear {
    display: none;
    height: 0;
    width: 0;
}

or, if anyone can tell me how to get that to work that would also be acceptable, but I would rather have it gone altogether.

Share Improve this question asked Jan 27, 2017 at 18:12 captainKirk104captainKirk104 1871 gold badge3 silver badges7 bronze badges 6
  • And, what is an "input clear 'X'"? – Scott Marcus Commented Jan 27, 2017 at 18:17
  • 1 That should work, Make sure you're running the page in standards mode. – Teemu Commented Jan 27, 2017 at 18:17
  • 1 Seems to work fine: jsfiddle/o55qyjsp The ments on this answer suggest that there's no way to hide it in the Modern UI mode or in Compatibility Mode. Make sure your site isn't showing up in patibility mode. – JLRishe Commented Jan 27, 2017 at 18:18
  • @ScottMarcus It's an icon that shows up when a text input has content in it. Clicking the X clears it. – JLRishe Commented Jan 27, 2017 at 18:19
  • 1 @JLRishe I lied. I had patibility mode on. I didn't remove the tag ...meta(http-equiv= "X-UA-Compatible", content= "IE=9")... My confusion, thanks. – captainKirk104 Commented Jan 27, 2017 at 18:42
 |  Show 1 more ment

2 Answers 2

Reset to default 5

(adding my ment from above as an answer since it turned out this was the cause of OP's issue)

Your CSS is fine:

input::-ms-clear {
    display: none;
    height: 0;
    width: 0;
}
<input type="text" />

There is no way to hide the X if the browser is running in Modern UI ("Metro") mode or if the page is rendering in Compatibility Mode.

So triple check that there's nothing in your markup that would cause the browser to use patibility mode. If your users are using the Modern UI for some reason, there's not much you can do about that.

This works for me in IE 11 (IE 11 Document Mode)

::-ms-clear {
  display:none;
}

It's slightly different than your selector which includes input. I don't see why that should make a difference, but you should try the selector as I have it (without any tag prefix).

发布评论

评论列表(0)

  1. 暂无评论