简体   繁体   English

使用 JQuery 从 IE 中的输入电话字段中删除“X”

[英]Remove "X" from input telephone field in IE using JQuery

I have an HTML input field of type telephone and I want to remove the "X" from the field (as shown below):我有一个电话类型的 HTML 输入字段,我想从字段中删除“X”(如下所示):

input type telephone field输入类型电话字段

I am able to do it with the following CSS code snippet:我可以使用以下 CSS 代码片段来做到这一点:

input[name=phone]::-ms-clear {  
    display: none; width : 0; height: 0; 
}

But I want this rule applied to a specific page and not to the entire input type telephone fields.但我希望将此规则应用于特定页面,而不是应用于整个输入类型电话字段。

I tried JQuery code:我试过 JQuery 代码:

phone.css("-ms-clear", "display: none; width : 0; height: 0") 

but that didn't work.但这没有用。

My specific question is how can I write the aforementioned CSS code in JQuery css method?我的具体问题是如何在 JQuery css方法中编写上述 CSS 代码?

With a little CSS magic you can create a pseudo-element to cover it up:使用一点 CSS 魔法,您可以创建一个伪元素来掩盖它:

 .tel { position: relative; display: inline-block; } .tel::after { content: ""; display: block; height: calc(100% - 2px); width: 20px; background-color: white; position: absolute; right: 1px; top: 1px; }
 <div class="tel"> <input type="tel" /> </div>

Welcome to stack-overflow!欢迎使用堆栈溢出! As per discussion in comments here is your answer.根据评论中的讨论,这里是您的答案。

Its simple (you don't need JS for doing this small job) On specific page body tag in which you want this behavior use css id selector and you can target these input and style it like它很简单(你不需要JS来做这个小工作)在你想要这种行为的特定页面body标签上使用 css id选择器,你可以定位这些input并设置它的样式

#pageid input[name=phone]::-s-clear { 
   display: none; 
   width : 0;
   height: 0; 
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM