首页 > Web开发 > 详细

[转]jQuery TextBox Water Mark with asp.net

时间:2014-01-21 16:35:50      阅读:428      评论:0      收藏:0      [点我收藏+]

本文转自:http://naspinski.net/post/jQuery-TextBox-Water-Mark-with-aspnet.aspx

 

I stole majority of this code from

http://www.aspcode.net/A-watermark-texbox-with-JQuery-and-aspnet.aspx

but I added a bit to make it swap css classes as well

bubuko.com,布布扣
 

$().ready(function() {
   swapValues = [];
   $(".wm").each(function(i) {
     swapValues[i] = $(this).val();
     $(this).focus(function() {
       if ($(this).val() == swapValues[i]) {
         $(this).val("").removeClass("watermark")

       } 
    }).blur(function() { 
        if ($.trim($(this).val()) == "") { $(this).val(swapValues[i]).addClass("watermark") } }) })
 }); 


To use it, make sure your TextBox has (one of) its css classes set to "wm". If you want a seperate style to be applied add that initially as well, in my example, it swaps "watermark" in and out as a css class.
 

<asp:TextBox ID="txt" runat="server"
   Text="this is the watermark" CssClass="wm watermark" /> 
bubuko.com,布布扣

[转]jQuery TextBox Water Mark with asp.net

原文:http://www.cnblogs.com/freeliver54/p/3527328.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!