• Resolved NollieHeel

    (@nollieheel)


    I have the following code, anybody know a way to condense it?
    It’s for a menu using PNG images that overlap – that’s why I change the z-index.

    $(“a.about”).hover(
    function () {
    $(“a.about”).css(“cursor”, “crosshair”);
    $(“a.about”).css(“zIndex”, “2”);
    },
    function () {
    $(“a.about”).addClass(“a.about”);
    }
    );

    $(“a.work”).hover(
    function () {
    $(“a.work”).css(“cursor”, “crosshair”);
    $(“a.work”).css(“zIndex”, “2”);
    },
    function () {
    $(“a.work”).addClass(“a.work”);
    }
    );

    $(“a.cv”).hover(
    function () {
    $(“a.cv”).css(“cursor”, “crosshair”);
    $(“a.cv”).css(“zIndex”, “2”);
    },
    function () {
    $(“a.cv”).addClass(“a.cv”);
    }
    );

    $(“a.contact”).hover(
    function () {
    $(“a.contact”).css(“cursor”, “crosshair”);
    $(“a.contact”).css(“zIndex”, “2”);
    },
    function () {
    $(“a.contact”).addClass(“a.contact”);
    }
    );

    $(“a.blog”).hover(
    function () {
    $(“a.blog”).css(“cursor”, “crosshair”);
    $(“a.blog”).css(“zIndex”, “2”);
    },
    function () {
    $(“a.blog”).addClass(“a.blog”);
    }
    );

    Also, even though this works –
    when I mouse over the menu items a second time, the z-index doesn’t change..

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Condensing my JS’ is closed to new replies.