Can I hide the HTML5 number input’s spin box?

后端 未结 17 1284
感动是毒
感动是毒 2020-11-22 05:08

Is there a consistent way across browsers to hide the new spin boxes that some browsers (such as Chrome) render for HTML input of type number? I am looking for a CSS or Jav

17条回答
  •  鱼传尺愫
    2020-11-22 05:44

    Not what you asked for, but I do this because of a focus bug in WebKit with spinboxes:

    // temporary fix for focus bug with webkit input type=number ui
    if (navigator.userAgent.indexOf("AppleWebKit") > -1 && navigator.userAgent.indexOf("Mobile") == -1)
    {
        var els = document.querySelectorAll("input[type=number]");
        for (var el in els)
            el.type = "text";
    }
    

    It might give you an idea to help with what you need.

提交回复
热议问题