Using a jQuery variable in two different functions -


I'm having trouble using this variable two different functions. First, I have a window for the element I calculate the required offset above (the variable of the leaf). After this, I have two different functions for which it needs to be used, but I can not get it to work.

  jquery (.df) {$ (function () {var topbar_o_height = $ (".pro.hehear"). External height (); var nav_o_height = $ (" (NAV "). External HEIGHT; if (topbar_o_height> gt; 0) {if ($ ('. NAV'). Haclus ('menu-fixed topbar') {var spacing = 10;} else {var spacing = 30;}} else {var spacing = 10;} var extra_height = topbar_o_height + nav_o_height + spacing; var leaves = $ (this hash). Offset (top) - extra_height; // place empty place for top position} // End function $ (".link_scroll") (function (event) {event.preventDefault (); $ ('html, body') .mate ({scrollTop: leaves}, 'slow');}); (Document.location.href.indexOf ('#')> gt; -1 / / will also use the leafpiece variable on here ...}}); // and dock ready  
< / Div>

You have to change the scope of the page's variable, try declaring it in the ready function:

  jQuery (document) .ready (function ($) {var of leaves; $ (function () {var topbar_o_height = $ (". Iter_Height (); var nav_o_height = $ (".nav"). External high (); if (topbar_o_height> gt; 0) {if ($ ('' menu (fixed-topbar ')) {var Spacing = 10;} else {var spacing = 30;}} other {var spacing = 10;} var extra_height = topbar_o_height + nav_o_height + spacing; place of leaves = $ (This.hash) .offet () top-extra_hete; / / Blank for the top menu} // end function $ (".link_scroll"). Click (function (event) {event.preventDefault (); // Now you get $ ('html, body') as the leaf Can get the place of. ({ScrollTop: Leaves }}; If (document.location.href.indexOf ('#')> gt; -1) {// Powerspace Variable will also be used here ... /// Now you can see the Spaces page Can use}}); // and doctor ready  

Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -