Delete input on search filter field when click

Description/Instructions

If you want to location filter field to autowipe when the user clicks on the field to enter a new location, instead of having to backspace the full text.

Instructions

You can use JavaScript to add a focus event, e.g. Templates/widgets/search-form/location-filter.php Copy to child theme

jQuery( $ => { $('.ts-filter-wrapper .ts-inline-filter:has(.inline-user-location)').on( 'focus', '.inline-input', e => { e.target.value = ''; e.target.dispatchEvent( new Event('input') ); } ); } );

  • JS
Copy Code

Let's Chat About this Snippet