Created
April 7, 2012 21:42
-
-
Save mlaug/2332310 to your computer and use it in GitHub Desktop.
Form info field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Form Info</title> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> | |
<script type="text/javascript"> | |
$(document).ready(function(){ | |
$(':input.form-input').live('focus', function(){ //get input field | |
$(this) | |
.closest("div") //get up to div element | |
.find(".form-info") //and search for corresponding form-info class to that input field | |
.show(); //show it | |
}).live('blur', function(){ | |
//once you leave the input field you might to some things | |
//... | |
//or just remove the element | |
$(this) | |
.closest("div") //get up to div element | |
.find(".form-info") //and search for corresponding form-info class to that input field | |
.hide(); //hide it | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<div> | |
<input type="text" name="blub" value="" class="form-input" /> | |
<span class="form-info" style="display:none;">my info to the customer</span> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment