如何在 Internet Explorer 10 中隱藏 [清除] 按鈕

警告

已淘汰、不受支援的 Internet Explorer 11 傳統型應用程式已於特定 Windows 10 版本透過 Microsoft Edge 更新永久停用。 如需詳細資訊,請參閱 Internet Explorer 11 傳統型應用程式淘汰常見問題集 (英文)。

本文提供在 Internet Explorer 10 中隱藏清除按鈕的解決方案。

原始產品版本: Internet Explorer 9 和更新版本
原始 KB 編號: 2813492

摘要

Windows Internet Explorer 10 為文字輸入欄位導入了新的 [清除] 按鈕。 此按鈕會在所有轉譯模式中顯示,但只有在文字輸入控件具有焦點且不是空的時才會顯示。 按下后,會清除輸入欄位。

另外還有一個名為 的新相關聯虛擬專案 ::-ms-clear 。 此虛擬元素會將一或多個樣式套用至 [清除] 按鈕。 下列程式代碼範例示範如何使用此虛擬元素來隱藏 [清除 ] 按鈕:

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta charset="utf-8" />
        <title></title>
        <style type="text/css">
            ::-ms-clear {
            ;
            }
        </style>
    </head>
    <body>
        <input type="text" />
    </body>
</html>

上述程式代碼在 Internet Explorer 10 檔模式中如預期般運作。

其他相關資訊

目前的設計是 [清除 ] 按鈕會顯示在所有 Internet Explorer 10 檔模式中,但樣式只能在 Internet Explorer 10 標準檔模式中套用。