Created
October 12, 2016 15:37
-
-
Save nickberens360/84322df2b934b4ca25ba103ef64ece68 to your computer and use it in GitHub Desktop.
wp contact form 7 float label
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
jQuery(document).ready(function ($) { | |
$(function () { | |
var onClass = "on"; | |
var showClass = "show"; | |
var labelOn = "labelOn"; | |
$(".js-floatInput").bind("checkval", function () { | |
var label = $(this).closest('.formGroup ').find(".js-floatLabel"); | |
if (this.value !== "") { | |
label.addClass(showClass); | |
$(this).closest('.formGroup ').addClass(labelOn); | |
} else { | |
label.removeClass(showClass); | |
$(this).closest('.formGroup ').removeClass(labelOn); | |
} | |
}).on("keyup", function () { | |
$(this).trigger("checkval"); | |
}).on("focus", function () { | |
$(this).closest('.formGroup ').find(".js-floatLabel").addClass(onClass); | |
}).on("blur", function () { | |
$(this).closest('.formGroup ').find(".js-floatLabel").removeClass(onClass); | |
}).trigger("checkval"); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment