Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Make Genesis search form input box text disappear on focus. JavaScript method. Source: https://sridharkatakam.com/make-search-form-input-box-text-go-away-focus-genesis/
input:focus::-webkit-input-placeholder { color:transparent; }
input:focus:-moz-placeholder { color:transparent; } /* Firefox 18- */
input:focus::-moz-placeholder { color:transparent; } /* Firefox 19+ */
input:focus:-ms-input-placeholder { color:transparent; } /* oldIE ;) */
<?php
add_action('wp_enqueue_scripts', 'prefix_clear_search_form_input_box');
function prefix_clear_search_form_input_box() {
wp_enqueue_script('clear-search-form', get_stylesheet_directory_uri() . '/js/clear-search-form.js', array('jquery'), '1.0.0', true);
}
jQuery(document).ready(function($) {
$('input').focusin(function() {
input = $(this);
input.data('place-holder-text', input.attr('placeholder'))
input.attr('placeholder', '');
});
$('input').focusout(function() {
input = $(this);
input.attr('placeholder', input.data('place-holder-text'));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.