Forums

[resolved] Help, jQuery and custom JS scripts not loading (4 posts)

  1. meckanism
    Member
    Posted 2 years ago #

    Hello everyone,

    I have a small problem with loading jQuery and JS scripts on wordpress.
    I got this menu made with jQuery that works perfectly well on a basic html page.

    Problem is i can't get the files to load as they should. I've looked around the web for jQuery tutorials for WP and i followed they're code but still nothing seems to work :\.

    So far i got the css for the menu working, but still no animation happening as it should..so jQuery isnt loading or the custom menu script isnt loading, or both :|

    i hope somebody here can give me a tip on how to fix this problem, thanks in advance :)

    btw u can see the site at http://www.miguelfreitas.pro.tc/

    Here's the code i put on the header.php file on my theme:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
    
    	<head profile="http://gmpg.org/xfn/11">
    
    		<title>
    			<?php if (is_home()) { echo bloginfo('name');
    			} elseif (is_404()) {
    			echo '404 Not Found';
    			} elseif (is_category()) {
    			echo 'Category:'; wp_title('');
    			} elseif (is_search()) {
    			echo 'Search Results';
    			} elseif ( is_day() || is_month() || is_year() ) {
    			echo 'Archives:'; wp_title('');
    			} else {
    			echo wp_title('');
    			}
    			?>
    		</title>
    
    	    <meta http-equiv="content-type" content="<?php bloginfo('html_type') ?>; charset=<?php bloginfo('charset') ?>" />
    		<meta name="description" content="<?php bloginfo('description') ?>" />
    		<?php if(is_search()) { ?>
    		<meta name="robots" content="noindex, nofollow" />
    	    <?php }?>
    
    		<link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); ?>" media="screen" />
    	  <link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" />
    		<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
    
        <?php wp_enqueue_script("jquery"); ?>
    
    		<?php wp_head(); ?>
    
    	<script type="text/javascript"
       src="<?php bloginfo("template_url"); ?>/style/js/menu.js"></script>
    
      </head>
    
    	<body>
    
        <ul id="topnav">
            <li><a href="#">Home</a></li>
            <li><a href="#">About me</a></li>
            <li><a href="#">Portfolio</a></li>
            <li><a href="#">Lab</a></li>
            <li><a href="#">Contacts</a></li>
        </ul> 
    
      	<h1><a href="<?php echo get_option('home'); ?>/"><?php bloginfo('name'); ?></a></h1>
    		<p><?php bloginfo('description'); ?></p>
    		<ul>
    <?php wp_list_pages('title_li='); ?>
    		</ul>
  2. stvwlf
    Member
    Posted 2 years ago #

    Hi

    When I do View Source on your homepage I see this included.

    <link href="/zzz/css.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="/zzz/gas.js"></script>

    The browser is not finding your css or javascript files at those URL's.
    If that is your live site you need to correct those links.

  3. meckanism
    Member
    Posted 2 years ago #

    ok problem solved, it was the jquery :\ wordpress is fine. Sorry for wasting your time :\

  4. stvwlf
    Member
    Posted 2 years ago #

    Hi

    I don't see exactly where it is coming from, but the browser is picking up this jQuery code from someplace. Its not in the script you are including, but its causing an error so the rest of your script is not being executed.

    <script type="text/javascript">
        $(document).ready(function() {
            $('button.alert').click(function() {
            alert('this is an alert message');
          });
        });
    </script>

    It seems like that's not supposed to be there in the first place but its crashing because of the leading dollar sign which as you know can't be used in WordPress.

Topic Closed

This topic has been closed to new replies.

About this Topic