This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Clear the searchfield content automatically

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Clear the searchfield content automatically

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #55948
    shop_aZynshop_aZyn
    Participant

    Hi there,

    how can I clear the searchfield content automatically if the search field is out of focus? If I deselect the searchfield I want the search box placeholder text to appear again.

    Thanks in advance!

    #55951
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi!

    While there is no option for that, but it is possible via a small custom coded snippet:

    add_action(
    	'wp_footer',
    	function () {
    		?>
    		<script>
    			jQuery(function($){
    				$('.asp_m input.orig').on('blur', function(){
    					$(this).closest('.asp_m').find('input').val('');
    				});
    			});
    		</script>
    		<?php
    	}
    );

    Add this code via the Code Snippets plugin (or similar) or to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.

    #55952
    shop_aZynshop_aZyn
    Participant

    Thank you Ernest, it works!

    #55953
    Ernest MarcinkoErnest Marcinko
    Keymaster

    You cannot access this content.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.