Title: jQuery click function issue
Last modified: August 21, 2016

---

# jQuery click function issue

 *  [Mart89](https://wordpress.org/support/users/mart89/)
 * (@mart89)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/jquery-click-function-issue/)
 * Hello, I have this code as show below and it works exactly as intended apart 
   from the fact that i have to click the page once before the buttons work.
 * I know this is caused by:
 * `jQuery(document).click(function(){`
 * but, when I try to replace this with anythiung else like:
 * `jQuery(document).ready(function(){`
 * for example, it no longer works. As far as i can remember the (document).click
   fucntion is there completely by accident and yet its needed for it to work properly,
   what am i missing?
 *     ```
       jQuery(document).click(function(){
       		jQuery('.toggle-on').click(function(){
       				jQuery('.post-info').addClass("post-info-toggle-off");
       				jQuery(this).addClass("toggle-off");
       				jQuery(this).removeClass("toggle-on");
   
       		});
       		jQuery('.toggle-off').click(function(){
       				jQuery('.post-info').removeClass("post-info-toggle-off");
       				jQuery(this).addClass("toggle-on");
       				jQuery(this).removeClass("toggle-off");
       		});
       		jQuery('.list-toggle').click(function(){
       				jQuery('.post-text').hide();
       				jQuery('.post-list').show();
       				jQuery('.info-toggle').addClass("toggle-off");
       				jQuery('.info-toggle').removeClass("toggle-on");
       		});
       		jQuery('.info-toggle').click(function(){
       				jQuery('.post-text').show();
       				jQuery('.post-list').hide();
       				jQuery('.list-toggle').addClass("toggle-off");
       				jQuery('.list-toggle').removeClass("toggle-on");
       		});
       	});
       ```
   

Viewing 1 replies (of 1 total)

 *  Thread Starter [Mart89](https://wordpress.org/support/users/mart89/)
 * (@mart89)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/jquery-click-function-issue/#post-5045709)
 * anyone??

Viewing 1 replies (of 1 total)

The topic ‘jQuery click function issue’ is closed to new replies.

## Tags

 * [addClass](https://wordpress.org/support/topic-tag/addclass/)
 * [jquery](https://wordpress.org/support/topic-tag/jquery/)
 * [Ready](https://wordpress.org/support/topic-tag/ready/)
 * [toggle](https://wordpress.org/support/topic-tag/toggle/)

 * 1 reply
 * 1 participant
 * Last reply from: [Mart89](https://wordpress.org/support/users/mart89/)
 * Last activity: [11 years, 9 months ago](https://wordpress.org/support/topic/jquery-click-function-issue/#post-5045709)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
