- This topic has 12 replies, 3 voices, and was last updated 8 years, 5 months ago by
Tom.
-
AuthorPosts
-
February 5, 2015 at 9:21 am #72608
Bill
Hi, trying to use a jquery script with this theme. I see that jquery is loaded with the following in the <head> of the page:
<script type=’text/javascript’ src=’http://mpwrestling.com/wp-includes/js/jquery/jquery.js?ver=1.11.1′></script>
Here is the script I’m trying to run:
$(document).ready(function() {
var w = $(window);
var masthead = $(‘#site-navigation’);
var adminbar = $(‘#wpadminbar’);var a = adminbar.height();
var o = adminbar.length > 0 ? a : 0;
var h = $(‘.site-branding’).height();
var m = masthead.offset().top;w.scroll(function() {
var st = w.scrollTop();
if(st > h)
{
masthead.css({‘position’ : ‘fixed’, ‘top’ : o})
}
else
{
masthead.css({‘position’ : ‘absolute’, ‘top’ : 0})
}})
});
Basically, it’s a script to fix the gray bar to the top of the page as it scrolls there. It’s a script I’ve run on several other websites successfully. However, I get “Uncaught TypeError: undefined is not a function” in the console when it’s run. It’s acting like jquery’s not there.
So I tried to insert a link to a “fresh” jquery library. My script works fine now; however, the nav menu dropdowns freeze after I mouse over a menu item.
Anyone else have this problem?
February 5, 2015 at 9:54 am #72621Tom
Lead DeveloperLead DeveloperIn order for jQuery to work with WordPress, you need to change your very first line from:
$(document).ready(function() {
to:
jQuery(document).ready(function($) {
WordPress needs you to specify that you’re using jQuery, as it supports multiple other libraries as well.
Let me know if that fixes it π
February 5, 2015 at 10:18 am #72631Bill
That did it. Thanks!
February 5, 2015 at 11:01 am #72644Tom
Lead DeveloperLead DeveloperYou’re welcome!
May 4, 2015 at 4:13 am #105278Thomas Furmato
Where is this first line?
May 4, 2015 at 4:16 am #105279Thomas Furmato
I’m using layerslider and the contents are not showing in the container.
May 4, 2015 at 8:30 am #105327Tom
Lead DeveloperLead DeveloperThe above was for writing his own jQuery.
Can you link me to your site where layerslider isn’t working?
Thanks!
May 4, 2015 at 11:35 am #105362Thomas Furmato
May 4, 2015 at 1:16 pm #105379Tom
Lead DeveloperLead DeveloperHmm, looking like more of a layer slider issue.
Is the text you’re wanting to show up called “Home Automation”?
If so, is it supposed to be an image, or text? Right now, it’s set to be an image, but there’s no image URL, so it’s using the alt tag of the image (Home Automation).
May 4, 2015 at 3:21 pm #105398Thomas Furmato
Yes. I’ll drag it into their forum then. Thank you for your help on this.
May 4, 2015 at 3:39 pm #105399Tom
Lead DeveloperLead DeveloperNo worries. Let me know if there’s anything I can do π
May 4, 2015 at 7:18 pm #105421Thomas Furmato
Well, since you asked….
I’d like to turn the top menu bar into a responsive block, that holds only phone # and address. It would need two divs I guess, so that when the site is shrunk the phone # is on top of the address. ( I currently disabled the top menu bar )
The reason being is I don’t want them to disappear when in mobile, and the don’t have to be a nav menu.
May 4, 2015 at 11:37 pm #105496Tom
Lead DeveloperLead DeveloperYou could add something like this into GP Hooks (Above Header):
<div class="grid-container grid-parent"> <div class="grid-50"> Phone number </div> <div class="grid-50"> Address </div> </div>
The above will show the phone number on the left, and address on the right. Then, on mobile, the phone will be above the address.
Let me know if that helps or not π
-
AuthorPosts
- You must be logged in to reply to this topic.