Skip to content Skip to sidebar Skip to footer

JavaScript To JQuery Syntax Still Need Help On Converting

I can not find out what is going wrong while running. Here I'm trying to re-write JavaScript to jQuery syntax. What exactly is incorrect? What I'm doing wrong. Legacy >> var

Solution 1:

You're missing parenthesis on most of your calls.

Declaring the height should look like this

$('ul#navmenu').height($('ul#navmenu').parent().height() -1)

You need to use .parent() not .parent

$('ul#navmenu').parent().bind('mouseover'

Below, it seem as if you are trying to first the first available ul within #navmenu. When you use [0] you're actually calling .get() which converts the jQuery object to a javascript DOM element. Doing that will remove the ability for you to run jQuery functions against it. Also, chaining doesn't happen like that for selectors. Also, .css() will accept an object with key:value pairs.

$(this).find('ul:first').css({
    "visibility" : "visible",
    "z-index" : 0
});

Once again, missing the () for .parent()

$('ul#navmenu').parent().bind('mouseout',

And again, the selector chain is wrong.

$(this).find('ul:first').css({
    "visibility" : "hidden",
    'z-index' : 100
});

Solution 2:

Height is a method, not a property. You have to set it likewise:

$('ul#navmenu').height($('ul#navmenu').parent.height + "-1px");

Post a Comment for "JavaScript To JQuery Syntax Still Need Help On Converting"