Revision: 50921
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at September 9, 2011 01:55 by thursday0384
Initial Code
$(document).ready(function(){
jQuery.fn.inputtoggle = function(){
$(this).each(function(index){
var myvalue = $(this).attr("value");
$(this).focusin(function(){
if($(this).val() == myvalue)
$(this).val("");
});
$(this).focusout(function(){
if($(this).val() === "")
$(this).val(myvalue);
});
});
};
//call custom inputtoggle() method on all inputs
//you could also be more specific, and write: $("input[type=text]").inputtoggle();
$("input").inputtoggle();
//close jquery
});
html:
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
jQuery