プラグインは、その中にこれを行います:
$(this).addClass("disabled");
それはプレースホルダーテキストを使用する場合。
input {
font-size: 13px;
color: #000;
}
input.disabled {
font-size: 12px;
color: #666;
}
をそのようなフォントサイズを変更する奇妙な視覚効果を引き起こす可能性がありますが、明示的な高さを使用することによって、それらを避けることができるかもしれません:だから、あなたは自分のCSSでこのような何かを置くことができるはずです。おそらく色を変えて、フォントサイズをIMHOのままにしておく方が良いでしょう。
同じことを試すこともできますが、これはplaceholder
の代わりにtitle
属性を使用し、含まれるフォームが送信されるときにプレースホルダテキストもクリアします。
(function($) {
$.fn.egText = function(options) {
options = $.extend({ }, $.fn.egText.defaults, options || { });
var $all = this;
$all.focus(function() {
var $this = $(this);
if(!$this.data(options.dataKey))
$this.data(options.dataKey, 'yes').removeClass(options.egClass).val('');
})
.blur(function() {
var $this = $(this);
if($this.val() == '')
$this.addClass(options.egClass).removeData(options.dataKey).val($this.attr('title'));
else
$this.data(options.dataKey, 'yes');
})
.blur();
$.unique($all.closest('form')).submit(function() {
$all.each(function() {
var $this = $(this);
if(!$this.data(options.dataKey))
$this.val('');
});
return true;
});
};
$.fn.egText.defaults = {
dataKey: 'egText', // The key we use for storing our state with .data(), just in case there are conflicts...
egClass: 'lolite' // The CSS class to add to the <input> when we're displaying the example text.
};
})(jQuery);
感謝を:ここで
は、上記のコードとも私は私のコードについて、もう少し情報が書いた記事のための私のworking ghost text exampleです。それは助けになった。 :) – ptamzz