Zend certified PHP/Magento developer

Jquery code doesn’t work when deployed but runs fine in the browser console in Magento cart page

We’re trying to just display the text in the code below if the page is the cart page so that visitors are aware that they can add a gift message to their order. Code works fine by displaying the text in the page when it is run in the Chrome browser console. But when I deploy the code on Magento server, it does nothing. Can you please help identify the cause of the issue?

if (document.location.href.indexOf("/checkout/cart") > -1){
    $(".gift-item-block>.title,.action-gift").css("color","#00008B").after('<div style="display:inline-block;color:#00008B;size:8px;width:600px;margin-top:-20px">We cannot gift wrap this these items.  We will mail a gift card the day of your order, to arrive before or on the day your gift arrives. Click &quot;Gift options&quot; to enter your message.</div>');
}