Connect with us

News

How to: Show/Hide any div box with jQuery in WordPress

If you take a look at my current sidebar (right) and see the heading Google Search you’ll notice that when you click it the Google Search box show’s into view.

Let me show you how this is done.

First make sure that your WordPress site is calling jQuery, buy pluggin this code into our header.php file above the <?php wp_head(); ?> text:

<?php wp_enqueue_script('jquery'); ?>

Then anywhere above the </head >, plug this code in:

<script type="text/javascript">
jQuery(document).ready(function() {
 // hides the slickbox as soon as the DOM is ready
  jQuery('#toggle-search').hide();

 // toggles the slickbox on clicking the noted link
  jQuery('a#slick-slidetoggle').click(function() {
	jQuery('#toggle-search').slideToggle(400);
	return false;
  });
});
</script>

That’s simple, huh. Okay now lets write the Search code:

<h2><a href="#" id="slick-slidetoggle">Google Search</a></h2>
	<div id="toggle-search" style="padding:10px;">
    <form method="get" id="search" action="<?php bloginfo('home'); ?>/">
        <div>
            <input type="text" value="Enter Keyword" onclick="this.value='';" name="s" id="s" />
            <input type="text" name="search-button" id="search-button" value="<?php _e('Search') ?>" />
        </div>
    </form>
</div>

That’s it.

Random Search Terms

Title

Top Articles

powered by WassUp

Recent Posts: Fully Net Worth . com

City Girls Net Worth: 5 Interesting Facts About The Hip hop duo

City Girls Net Worth: 5 Interesting Facts About The Hip hop duo

City Girls is an American hip hop duo originally from Miami which consists of the rappers Caresha Romeka Brownlee (known as Yung Miami) and Jatavia Shakara Johnson (known as JT). Here are some facts about City Girls including their net worth, career and many more. 1. City Girls has an estimated net worth of $500,000 […]

Tasha K Net Worth: How Rich is the YouTube star Actually?

Tasha K Net Worth: How Rich is the YouTube star Actually?

Tasha K is an American social media personality and pop culture aficionado. She is best known for her YouTube channel ‘unWinewithTashaK’. Tasha K net worth is under review and is not available at the moment. Tasha whose real name is Latasha Transrina Kebe was born on March 10, 1982, in Panama City, Florida but later […]

Roman Kemp Net Worth: How Rich is the Radio host Actually?

Roman Kemp Net Worth: How Rich is the Radio host Actually?

Roman Kemp is an English radio host and presenter. He presents for the national radio network Capital FM and is part of the nineteenth series of I’m a Celebrity…Get Me Out of Here!. As of 2019, Roman Kemp net worth is estimated to be £2 million. Kemp was born on 28 January 1993, in Los […]

%d bloggers like this: