How to get cookie value when $.cookie error come in console

How to solve error comes when trying to use cookie value store in the browser.

 

when trying to use a cookie value which stores in the browser by javascript and error come in browser console $.cookie is not define, so add jquery cookie library in HTML code. The library is mention below.

 

Include below jquery library after jQuery call

<script type=”text/javascript” src=”https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js”></script>

Detail code.

<script type="text/javascript" src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>

<script type="text/javascript">
jQuery(document).ready(function(){
var hubsportCookie = $.cookie('hubspot_marketplace'); 
if(hubsportCookie == 'hubspot'){
jQuery('#leadSource').val('Hubspot Marketplace');
}
});

</script>