admin管理员组

文章数量:1428559

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

Share Improve this question edited May 7, 2019 at 10:34 tru.d 1861 gold badge1 silver badge17 bronze badges asked May 7, 2019 at 9:33 DennisDennis 216 bronze badges 3
  • 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
Add a comment  | 

1 Answer 1

Reset to default 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")
});

本文标签: wp queryHelp with showing text when something is entered in my search bar