-1

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'.

enter image description here

  • where is your search input? show the code, sharing snapshot of the code makes us to help more difficult – Vishwa May 7 '19 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 May 7 '19 at 10:04
  • I found it out, thanks for the help though. :) – Dennis May 7 '19 at 10:15
0

You 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")
});
  • I found it out, thanks for the help though. :) – Dennis May 7 '19 at 10:15
  • @Dennis you can accept the answer if it helps you.. good luck – Vishwa May 7 '19 at 10:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.