I'm having troubles replacing text when there is something entered in the search form.
As you can see in the image below i want to replace 'mijn gemeente' with the get_search_query
text if i'm searching something, if nothing is searched it should show 'mijn gemeente'.
I'm having troubles replacing text when there is something entered in the search form.
As you can see in the image below i want to replace 'mijn gemeente' with the get_search_query
text if i'm searching something, if nothing is searched it should show 'mijn gemeente'.
- where is your search input? show the code, sharing snapshot of the code makes us to help more difficult – Vishwa Commented May 7, 2019 at 9:49
- Search input is in my sidebar. I can get the text from the input and show it but i want it only to show if there was anything searched. When there is nothing searched it should show 'mijn gemeente'. So basically i need some sort of IF loop i think. – Dennis Commented May 7, 2019 at 10:04
- I found it out, thanks for the help though. :) – Dennis Commented May 7, 2019 at 10:15
1 Answer
Reset to default 0You can do that using jQuery's focus
function. add following into your php file inside <script>
tags.
$("#your-searchinput-id").focus(function() {
$("h4.title_sidebarsub").text("<?php echo $string ?>")
});
$(this).blur(function() {
$("h4.title_sidebarsub").text("mijn gemeente")
});