$(document).ready(function() {
$(":input[data-watermark]").each(function() {
$(this).val($(this).attr("data-watermark"));
$(this).css("color", "#a8a8a8");
$(this).bind("focus", function() {
if ($(this).val() == $(this).attr("data-watermark")) $(this).val('');
$(this).css("color", "#000000");
});
$(this).bind("blur", function() {
if ($(this).val() == '') {
$(this).val($(this).attr("data-watermark"));
$(this).css("color", "#a8a8a8");
}
else {
$(this).css("color", "#000000");
}
});
});
});
風格
<style>
.placeholder {
color: #a8a8a8;
}
::-webkit-input-placeholder {
color: #a8a8a8;
}
:-moz-placeholder {
color: #a8a8a8;
}
.home_textbox{width:155px; height:25px; border:1px solid #c9c5c1; border-radius:5px; position:relative; font-size:13px; color:#b5b0aa; font-family:"Myriad Pro"; padding:0 5px;}
文本
<input type="text" name="TxtLogin" id="TxtLogin"
class="home_textbox" runat="server" tabindex="1" style="color:Black;" data-watermark="Username" />
您是指具有各種水印嗎? – liquidsnake786
你是什麼意思liquidnake .. – Sasidharan
你想水印文本框,不是嗎? – tariq