在输入双击时隐藏透明文本

时间:2017-07-18 09:04:52

标签: javascript jquery html css

我不希望用户看到在输入中输入的文本,我已经使用public class Test { private Map<Object, Object> map = new HashMap<>(); private ReentrantReadWriteLock reentrantReadWriteLock = new ReentrantReadWriteLock(); public void process() { methodThatModifiesMap(); methodThatJustReadsmap(); } private void methodThatModifiesMap() { //if the code involves modifying the structure of the map like 'put(), remove()' i will acquire the write reentrantReadWriteLock reentrantReadWriteLock.writeLock().lock(); try { //DO your thing and put() or remove from map } finally { //Dont forget to unlock reentrantReadWriteLock.writeLock().unlock(); } } private void methodThatJustReadsmap() { // if all you are doing is reading ie 'get()' reentrantReadWriteLock.readLock().lock(); // this does not block other reads from other threads as long as there is no writes during this thread's read try { } finally { reentrantReadWriteLock.readLock().unlock(); } } } 并且文本被隐藏但是当用户双击输入时,文本变得可见!通过双击选择输入时,如何隐藏它。 提前致谢。

color: transparent
#loginCard{
  color: transparent;
}

6 个答案:

答案 0 :(得分:1)

在CSS中使用此代码更改文本标记高亮颜色

N.B:您还可以使用transparent颜色。我用白色作为背景是白色的。但使用transparent会更明智。

::selection {
  background: #ffb7b7; /* WebKit/Blink Browsers */
}
::-moz-selection {
  background: #ffb7b7; /* Gecko Browsers */
}

::selection {
  background: #fff; /* WebKit/Blink Browsers */
}
::-moz-selection {
  background: #fff; /* Gecko Browsers */
}

.sample {
  color: #fff;
}
<input type="text" class="sample" />

答案 1 :(得分:0)

我不知道你为什么要这样做但你可以使用css:

input, textarea { 
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Safari */
 -khtml-user-select: none; /* Konqueror HTML */
   -moz-user-select: none; /* Firefox */
    -ms-user-select: none; /* Internet Explorer/Edge */
        user-select: none; /* Non-prefixed version, currently
                              supported by Chrome and Opera */

}

答案 2 :(得分:0)

String[] s = {"818001,818002","121212","151515,151515"};
for(int i=0; i<s.length; i++) {
  s[i] = s[i].replace(",", "");
}
System.out.print(Arrays.toString(s));  // [818001818002, 121212, 151515151515]

会让它变得透明

答案 3 :(得分:0)

您可以将::selection设置为transparent

Support

input {
  color: transparent;
}

input::selection {
 color: transparent;
}
<input>

答案 4 :(得分:0)

只需添加

::selection {
  background: transparent;
}

对于firefox:

::-moz-selection {
  background: transparent;
}

答案 5 :(得分:0)

HTML

<input type="password" id="password" >

Jquery的

$(document).ready(function(){

    $('#password').dblclick(function(){
     $('#password').attr("type","text");
    })

});