背景は単色ではないため、テキストを背景と同じ色にすることはできません。
transparent
色はどうですか?
これは役に立ちますか?
input[type="text"] {
color: transparent;
}
JSBin デモ #1
アップデート:
@Shomz のアイデアを実装しました。カーソルを先頭に置いておくか、すべての文字を*
. 私はjQuery
イベントをバインドするために使用しました:
jQuery バージョン:
var holder = [], exceptions = [13];
var hideChar = function(elm) {
elm.value = '';
// Or
// elm.value = elm.value.replace(/[^*]/, '*');
};
$('#console').keydown(function(e) {
if (e.which === 8) {
holder.pop();
}
}).keypress(function(e) {
if ($.inArray(e.which, exceptions) === -1) {
holder.push(String.fromCharCode(e.which));
}
var _this = this;
setTimeout(function() {
hideChar(_this);
}, 1);
}).keyup(function() {
$('#holder').val(holder.join(''));
});
HTML:
<input id="console" type="text" value="">
<input id="holder" type="hidden">
JSBin デモ #2
純粋な JavaScript バージョン? もちろん!
それは長い話です。デモを確認してください。
JSBin デモ #3