2016-09-16 1 views
0

이 질문에 대한 답변이 여러 가지 있습니다.입력 유형 = "텍스트/검색"컨트롤에서 'X'를 제거하는 방법

같은 :

ans 1

ans 2

ans 3

하지만, 그 모든 시도했다, 그러나 아직도 나는에서 "X"를 제거 할 수 없습니다 입력 필드 난 그냥 간단한 입력 제어 생성

:

input[type=text]::-ms-clear { display: none; width : 0; height: 0; } 
input[type=text]::-ms-reveal { display: none; width : 0; height: 0; } 
input[type="search"]::-webkit-search-decoration, 
input[type="search"]::-webkit-search-cancel-button, 
input[type="search"]::-webkit-search-results-button, 
input[type="search"]::-webkit-search-results-decoration { display: none; } 

#RemoveX::-ms-clear { display: none; width : 0; height: 0; } 
#RemoveX::-ms-reveal { display: none; width : 0; height: 0; } 
#RemoveX::-webkit-search-decoration, 
#RemoveX::-webkit-search-cancel-button, 
#RemoveX::-webkit-search-results-button, 
#RemoveX::-webkit-search-results-decoration { display: none; } 

내가 IE 11 사용하고 미세, 나는이 테스트를하고 있지 않다되는 호환성 모드의 모든 것을 확인했다 : 여기

<input type="text" id="RemoveX" /> 

내 CSS입니다 모든 브라우저에서 (필자는 필요 없음) X을 IE 10+ 브라우저의 입력 필드에서 제거하기 만하면됩니다.

어떤 도움을 주시면 감사하겠습니다.

답변

0

(테스트했지만 작동해야되지 않음)

$('#yourInput').bind('input', function() { 
    var current = $('#yourInput').val(); 
    var newData = current.replace("X",""); 
    $('#yourInput').val(newData); 
}); 

지금 테스트 완료 :

<!doctype html> 
 
<html> 
 
\t <head> 
 
\t \t <meta charset="utf-8"> 
 
\t \t <script src="https://code.jquery.com/jquery-3.1.0.min.js"></script> 
 
\t \t <title>asd</title> 
 
\t </head> 
 
\t <script type="text/javascript"> 
 
\t $(document).ready(function(){ 
 
\t \t $('#myInput').bind('input',function() { 
 
\t \t \t var current = $('#myInput').val(); 
 
\t \t \t var newData = current.replace("X",""); 
 
\t \t \t newData = newData.replace("x",""); // small x if you want 
 
\t \t \t $('#myInput').val(newData); 
 
\t \t }); 
 
\t }); 
 
\t </script> 
 
\t <body> 
 
\t \t <input type="text" id="myInput" /> 
 
\t </body> 
 
</html>

관련 문제