Title: Javascripts not initiating correctly
Last modified: August 20, 2016

---

# Javascripts not initiating correctly

 *  [thesublimeobject](https://wordpress.org/support/users/thesublimeobject/)
 * (@thesublimeobject)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/javascripts-not-initiating-correctly-1/)
 * So, I am not that new to using jquery, but I haven’t used wordpress for that 
   long. I am working on a site and a couple of the scripts I am running seem to
   either (a) take a second to initiate or (b) initiate too soon, before they should,
   and then there must be user interaction for them to correct themselves. I’m not
   using enqueue for them right now, which I know you’re supposed to, but I don’t
   think it should be causing this problem. Anyone have an idea to why?
 * For an example check out the drop down header here: nextworld.kbddev.com. It 
   isn’t supposed to drop down until a certain point in the page, but it shows up
   anyway when the page loads, then disappears upon scroll.
 * Another example, on the team page, the photos are scripted to go black/white,
   and they do, but not after they first show up as color.
 * _[Moderator note: Duplicate thread removed]_

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Moderator [t-p](https://wordpress.org/support/users/t-p/)
 * (@t-p)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/javascripts-not-initiating-correctly-1/#post-3477267)
 * [http://codex.wordpress.org/Using_Your_Browser_to_Diagnose_JavaScript_Errors](http://codex.wordpress.org/Using_Your_Browser_to_Diagnose_JavaScript_Errors)
 *  Thread Starter [thesublimeobject](https://wordpress.org/support/users/thesublimeobject/)
 * (@thesublimeobject)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/javascripts-not-initiating-correctly-1/#post-3477269)
 * Thank you, I didn’t know about the script debug. Unfortunately, that didn’t help,
   and I know there aren’t any errors in the script already. The scripts themselves
   work, they just aren’t initiating correctly. Any other suggestions?
 *  [WPyogi](https://wordpress.org/support/users/wpyogi/)
 * (@wpyogi)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/javascripts-not-initiating-correctly-1/#post-3477281)
 * [http://codex.wordpress.org/Using_Javascript](http://codex.wordpress.org/Using_Javascript)
 *  Thread Starter [thesublimeobject](https://wordpress.org/support/users/thesublimeobject/)
 * (@thesublimeobject)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/javascripts-not-initiating-correctly-1/#post-3477287)
 * Hey guys, seriously thanks for trying to help, but does anyone have maybe a particular
   possible solution to my problem? I’m not trying to be sarcastic, but I have tried
   some of these things and I am aware that the codex exists. I’ve done a lot of
   searching.
 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [13 years, 2 months ago](https://wordpress.org/support/topic/javascripts-not-initiating-correctly-1/#post-3477291)
 * Can you demonstrate the JavaScript and its correct behavior on [JSfiddle](http://jsfiddle.net/)?
   Then try switching themes to explore whether the issue is specific to your theme.
 *  Thread Starter [thesublimeobject](https://wordpress.org/support/users/thesublimeobject/)
 * (@thesublimeobject)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/javascripts-not-initiating-correctly-1/#post-3477306)
 * Sorry, I should have included the code. Silly me. I can do a Fiddle, but since
   it won’t really work very well due to the animation. What is supposed to happen
   is a secondary header is supposed to pop down when the scroll hits > 542. That
   IS happening. Exactly how I want it to. The problem is on the window load, the
   bar itself is showing up until the user scrolls, then it disappears, and works
   correctly. If you scroll back up, it works well, still. Only on the initial load
   is the drop-down bar appearing incorrectly (it shouldn’t appear at all.
 * Here is the code:
 *     ```
       <div id="follownav">
       	<div class="follownavwrap">
       		<nav>
       			<div id="nav-logo-2"><a href="<?php bloginfo('url'); ?>"><img src="<?php bloginfo( 'stylesheet_directory' ); ?>/images/footer_logo.png" width="225" id="navv-logo"></a></div>
       			<ul class="jsnav">
           			<li><a href="/companies">Companies</a></li>
           			<li><a href="/team">Team</a></li>
       			    <li><a href="/global">Global</a></li>
       			    <li><a href="/about">About</a></li>
       			    <li><a href="/contact">Contact</a></li>
       			</ul>
       		</nav>
       	</div>
       </div>
   
       #follownav {
       	height: 70px;
       	width: 100%;
       	background: #000;
       	position: fixed;
       	top:0;
       	z-index: 9999999;
       	padding: 0;
       	margin: 0;
       }
   
       .hide {
       	display: none;
       }
   
       .show {
       	display: block;
       }
   
       #follownav ul {
       	list-style: none;
       }
   
       #follownav ul li {
       	display: inline-block;
       }
   
       #follownav ul li a {
       	display: inline-block;
       	text-decoration: none;
       	color: #fff;
       	font-family: 'proxima-nova', sans-serif;
       	text-transform: uppercase;
       }
   
       #nav-logo-2 {
       	width: 200px;
       	margin: 0;
       	padding: 0;
       	float: left;
   
       }
   
       .jsnav {
       	width: 600px;
       	margin: 0;
       	padding: 0;
       }
   
       $(window).scroll(function(){
             if($(window).scrollTop() > 542){
                 $("#follownav").slideDown("fast");
                 $('#follownav').removeClass('hide').addClass('show');
   
             }
           });
           $(window).scroll(function(){
             if($(window).scrollTop() < 542){
                 $("#follownav").slideUp("fast");
             }
           });
       ```
   
 * Link to site:[nextworld.kbddev.com](http://nextworld.kbddev.com)
 * I should mention this is a custom theme, so I can’t switch themes.
 *  Moderator [t-p](https://wordpress.org/support/users/t-p/)
 * (@t-p)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/javascripts-not-initiating-correctly-1/#post-3477309)
 * > this is a custom theme, so I can’t switch themes.
 * perhaps you want to contact the theme’s vendor go get guidance as to how to use
   what you are trying to do.
 *  Thread Starter [thesublimeobject](https://wordpress.org/support/users/thesublimeobject/)
 * (@thesublimeobject)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/javascripts-not-initiating-correctly-1/#post-3477314)
 * [@t-p](https://wordpress.org/support/users/t-p/), I built the theme myself..

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Javascripts not initiating correctly’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 8 replies
 * 4 participants
 * Last reply from: [thesublimeobject](https://wordpress.org/support/users/thesublimeobject/)
 * Last activity: [13 years, 2 months ago](https://wordpress.org/support/topic/javascripts-not-initiating-correctly-1/#post-3477314)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
