0

I am fairly new to jquery and javascript, but certain that I can use it to get the result I desire. I would like to have the background-image of the add to cart button change on click. From my research,on this site and others,I have come to the code pasted below;for which the html is only the snippet for the button, which I copied from the Magento Go store source. I feel I am close but I think that I am not "identifying?"(for lack of the proper term) the class of the button correctly. If I had access to the php templates I think I would have an easier time customizing but this is the route that was chosen. I appreciate any insight given.

<script>
    google.load("jquery", "1.9.1");
    google.setOnLoadCallback(function() {
        $('btn-cart').onClick function() {
           $(this).css('background-image', 'url(image2)');
        });
    });
</script>

<style>
    .btn-cart{
        background-image: url('image1');
        width: 100px;
        height: 100px;
    }
</style>
<html>
<body>
    <button type="button" title="Add to Cart" class="button btn-cart" onclick="setLocation('http://charmit.gostorego.com/checkout/cart/add/uenc/aHR0cDovL2NoYXJtaXQuZ29zdG9yZWdvLmNvbS9jaGFybXMuaHRtbA,,/product/366/')">
    <span><span>Add to Cart</span></span></button>
</body>
</html>
4

0 回答 0