Skip to content

Instantly share code, notes, and snippets.

@rafaehlers
Created October 30, 2018 04:55
Show Gist options
  • Save rafaehlers/2428a87255e2db97db46b0dfd3b21974 to your computer and use it in GitHub Desktop.
Save rafaehlers/2428a87255e2db97db46b0dfd3b21974 to your computer and use it in GitHub Desktop.
Turn Search Bar labels into placeholders
<script type="text/javascript">
(function($){
$(document).ready(function(){
$("form.gv-widget-search :input").each(function(index, elem) {
var eId = $(elem).attr("id");
var label = null;
if (eId && (label = $(elem).parents("form").find("label[for="+eId+"]")).length == 1) {
$(elem).attr("placeholder", $(label).html());
$(label).remove();
}
});
});
})(window.jQuery);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment