SharePoint Timer February 5th, 2015

SharePoint has a nasty habit of fooling JavaScript into thinking the DOM is loaded when there are actually still elements popping in afterwards.  Here’s a dirty script for testing the existence of a given element when you’re in a pinch…

var wnt_spTimer,
    wnt_spElement;

 wnt_spTimer = window.setInterval(function(){
     wnt_spElement = $('div[data-widget="tools"] .heading-main h2').length;
     if(wnt_spElement === 0){
         console.log('******** VAUE OF ELEMENT IS ZERO ******** '+wnt_spElement);
     } else {
         console.log('******** VAUE OF ELEMENT = '+wnt_spElement);
         $('div[data-widget="tools"] .heading-main h2').html('Information Zone');
         clearInterval(wnt_spTimer);
         return;
     }
 }, 100);