javascript - how to create watermark effect using jquery in asp.net -


I got to do this but I found that it is not working because I have multiple squares in the same text box Are given. How to change it to work with many classes. I do not know how to use to work with selectors.

I'm using it like this

  & lt; Div class = "inbox3full" & gt; & Lt; Div class = "threeinbg" & gt; & Lt; Asp: text box id = "textart order" cssClass = "three water" text = '& lt;% # bind ("ordered order")% & gt; Runat = "server" tooltip = "Type your sort order" & gt; & Lt; / Asp: textbox & gt; & Lt; / Div & gt; & Lt; / Div & gt; With jquery as  

     .water {font-family: Tahoma, Arial, sans -serif; font-size: 75%; color: black;} & lt; script type = "text / javascript Repeat "& gt; $ (document) .ready (function () {$ (" .water "). AddClass ('watermark'); $ (" watermark "). Live ('focus', function () {$ Tb = $ (this); if ($ tb.val () == this.title) {$ tb.val (""); $ tb.removeClass ("water");}}) live ('blur' $ ($ .bb.val ()) == "") {$ tb.val (this.title); $ tb.addClass ("water" );}}) .blur ();}); Sys.WebForms.PageRequestManager.getInstance (). Add_endRequest (function () {$ (".water") .No (document.activeElement) .blur ();}); & Lt; / Script & gt;  

Instead you have a kind of fire, handler is easy to ignite, such as ( .live () has been edited to use because you are adding them to an UpdatePanel):

  $ (function () {$ $ (".") ("Watermark"); $ ("focus", function () {$ tb = $ (this); if ($ tb.val () == this.title) {$ tb .val (" "$; Tb.removeClass (" water ");}}) live ('blur', function () {$ tb = $ (this); if ($ .trim ($ tb.val ()) == "") {$ Tb.val (this.title); $ tb.addClass ("water");}}) .blur ();});  

This watermark / title is already empty in the box, which usually puts what you want. Also, when your panel page ends, you'll want to call .blur () on those elements so that you can apply a freshly watched watermark, such as:

  Sys WebForms.PageRequestManager.getInstance (). Add_endRequest (function () {$ (".water") .No (document.activeElement) .blur ();});  

This will blur all the elements except one currently centered, because the user does not have to interrupt typing.


Comments

Popular posts from this blog

paypal - How to know the URL referrer in PHP? -

oauth - Facebook OAuth2 Logout does not remove fb_ cookie -

wpf - Line breaks and indenting for the XAML of a saved FlowDocument? -