Last active
October 20, 2016 14:50
-
-
Save sewmyheadon/326cd4138e23408992ac7874f095cf6f to your computer and use it in GitHub Desktop.
Hide gravity forms field labels on focus or input
This file contains hidden or 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
** | |
* Remove labels from Gravity Forms form fields on focus and input | |
* Can easily be adapted to forms of any origin | |
*/ | |
jQuery(function ($) { | |
jQuery.fn.labelOver = function(overClass) { | |
return this.each(function(){ | |
var label = jQuery(this); | |
var f = label.attr('for'); | |
if (f) { | |
var input = jQuery('#' + f); | |
this.hide = function() { label.css({ display: "none" }) } | |
this.show = function() { if (input.val() == '') label.css({ display: "block" }) } | |
// handlers | |
input.focus(this.hide); input.blur(this.show); | |
//label.addClass(overClass).click(function(){ input.focus() }); // Should be able to remove this. | |
if (input.val() != '') this.hide(); | |
} | |
}) | |
} | |
$(document).ready(function() { | |
// Login | |
if($('.gfield label').length > 0){ $(".gfield label").labelOver(); } | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment