efficient use TextBox with jQuery

The default value of the sites setlemek Textboxların undoubtedly brings ease of use. So far in between existing code and is usually mixed with html, javascript codes unusable and do it again hallederdik:
able to bring this work a practical solution with jQuery. First, put the following code in javascript library. Putting Headera is sufficient.
  setDefault function (target, value) { 
	  if (value == "") { 
		  value = $ (target). attr ("defaultValue"); 
	  } 

		  $ (Target). Val (value); 

		  $ (Target). Focus (function () { 
			  if ($ (this). val () == value) { 
				  $ (This). Val (""); 
			  } 
		  }); 
		  $ (Target). Blur (function () { 
			  if ($ (this). val () == "") { 
				  $ (This). Val (value); 
			  } 
		  }); 
	  } 

Then the call is simple:
setDefault ('# user_login', 'Username');
0 saves
It liked the article, this article, please leave a comment and / or in the future to follow the articles published on your site's RSS feed .
This entry was posted in jQuery and tagged , , , , , . Bookmark the permalink .

Comments are closed.