Search code examples
jquerycssclickablemouse-cursor

Clickable block pointer


// clickable blocks
$(".product").click(
function () {
    window.location = $(this).find('a').attr("href").css("cursor", "pointer");
    return false;
});

The container is made clickable but the cursor remains the same. Why isn't the css selector working?


Solution

    1. Find all the products that have a link
    2. Puts a pointer as cursor
    3. Handle the click event to change location

    The code:

    $(".product:has(a[href])")
        .css("cursor", "pointer")
        .click(function()
        {
            window.location = $("a", this).attr("href");
        });