Problem: I am trying to display a map, but it does not load. I see an error in the JavaScript console:
Uncaught TypeError: Cannot read property 'top' of undefined
Solution: Fix JavaScript errors related to undefined elements by testing to see if those elements exist before performing calculations on them.
jQuery(document).ready(function($){ var $el = $('.bloc-localisation'); //record the elem so you don't crawl the DOM everytime // stop here if no bloc-localisation element exists on the current page if( $el.length == 0 ) { return; } var bottom = $el.offset().top + $el.outerHeight(true); // passing "true" will also include the top and bottom margin console.log('bottom bloc gauche : '+bottom);
Relevant Documentation:
http://api.jquery.com/
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 4 replies, has 2 voices.
Last updated by 5 years, 11 months ago.
Assisted by: Christian Cox.