Uncaught TypeError: Failed to execute 'observe' on 'MutationObserver': parameter 1 is not of type 'Node'
<p>so my code below works stand alone in a jsfiddle. but for some odd reason.. I get this error consistently after pushing it to a live server :/ and I can't figure out why...</p>

<p><strong>error</strong>:</p>

<pre><code>mycodewitherror.js:23 Uncaught TypeError: Failed to execute 'observe' on 'MutationObserver': parameter 1 is not of type 'Node'.
</code></pre>

<p><strong>js:</strong></p>

<hr>

<pre><code>$(document).ready(function() {
// The below collects user login name, new login date and time, and previous use URL
var element = document.querySelector('.pet-name'); 
// create an observer instance
var observer = new MutationObserver(function(mutations) {
      var username = $('.pet-name').text();
      var referrer = document.referrer;
      var date = new Date();
      var month = date.getUTCMonth() + 1;
      var day = date.getUTCDate();
      var year = date.getUTCFullYear();
      var time = date.toLocaleTimeString();
      var formattedDate = month + '/' + day + '/' + year;
    console.log("Pet Name Time"); 
      console.log(referrer); 
      console.log(petname); 
      console.log(time); 
      console.log(formattedDate);   
});

// configuration of the observer:

var config = { attributes: true, childList: true, characterData: true };

// pass in the target node, as well as the observer options
observer.observe(element, config);
</code></pre>