Return to Snippet

Revision: 50921
at September 9, 2011 01:55 by thursday0384

Initial Code
	jQuery.fn.inputtoggle = function(){
	    var myvalue = $(this).attr("value"); 
	      if($(this).val() == myvalue)
	      if($(this).val() === "")
        //call custom inputtoggle() method on all inputs 
        //you could also be more specific, and write: $("input[type=text]").inputtoggle();
//close jquery


very basic ... 

<input type="text" name="input_name" value="Your Value Name" />

Initial URL

Initial Description
This is a jQuery custom function used for clearing the default input values of input fields without having to add a class or inline javascript like onclick or onblur. Just write your input and give it a value like you normally would and then add this function and you're good to go.

Initial Title
jQuery input value text toggle

Initial Tags
form, jquery, function

Initial Language