@stragerの提案に基づいてこれを試して、次の優れた機能のコード
jQueryを作成しました。
$(":text[value='']").addClass('empty');
$(":text[value>='']").removeClass('empty');
$('.ez-edit').blur(function() {
if ($(this).val().length >= 0) {
$(this).removeClass('empty');
}
if ($(this).val().length <= 0) {
$(this).addClass('empty');
}
});
およびCSS:
input.ez-edit {
font-family:"Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, Verdana, sans-serif;
font-weight:bold;
display: inline;
padding:5px 8px 5px 2px;
background-color: transparent;
border-style: none;
border-top: 1px solid #cdcdcd;
color: inherit;
font-size: inherit;
}
input.ez-edit:hover {
text-decoration: underline;
/* following "pencil" img from: http://enon.in/6j */
background:url(../images/pencil.gif) no-repeat right #ffffdc;
border-style:1px hidden;
border-top:1px solid #fff;
border-right-color:#fff;
border-bottom-color:#fff;
border-left-color:#fff;
}
input.ez-edit:focus, input.ez-edit:focus:hover {
display:inline-block;
border:1px solid #4d4d4d;
font-size:12px;
background-color:#FFFFDc;
color:#333;
font-weight:normal;
}