title: Uncaught TypeError: Cannot read property 'on' of null
body: <p>I'm getting this Uncaught TypeError: </p>
  
  <p><a href="https://i.stack.imgur.com/XPMSZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XPMSZ.png" alt="enter image description here"></a></p>
  
  <p>I'm unsure what is causing it, maybes something to do with JQuery?</p>
  
  <p>Here is the exact code:</p>
  
  <pre><code>//when add to cart link is clicked...
  $('.addtocart').on('click', function(){
  
    //get the value of the "data-value" attribute for that link
    var vehicleRegistration = $(this).data('value');
    //save it to localStorage
    localStorage.setItem('vehicleRegistration', vehicleRegistration);
  
  
    //read from localStorage
    if( localStorage.getItem('vehicleRegistration') ){
      //add the value to the form input
      $('#field34').val( localStorage.getItem('vehicleRegistration') );
    }
  
  });
  </code></pre>
  
  <p>Here is the page that it is happening on: <a href="http://drivencarsales.co.uk/book-testdrive" rel="nofollow noreferrer">http://drivencarsales.co.uk/book-testdrive</a></p>
  
  <p>It's really got me stumped, if anyone can help me solve this it would be much appreciated.</p>
  
  <p>Thanks, Nick</p>