Thursday, 24 January 2013

Menu Mouse over and out using jquery

decalre anchor tags in html or design page

<a href="../UserPages/wpWelcome.aspx" id="aHome" onmouseover="fnMouseOver(this)"
    onmouseout="fnMouseOut(this)"><span>Home </span></a>



Write Jquery Functions in Script Tags

function fnMouseOver(obj) {
    $(obj).css({ 'font-weight': 'bold', 'color': 'orange' });
}

function fnMouseOut(obj) {
    var address = $(location).attr('href');
    var href = $(obj).attr('href');
    if (href !== '#') {
        href = href.substring(13);
        if (address.indexOf(href) >= 0) {
        }
        else {
            $(obj).css({ 'font-weight': 'normal', 'color': 'blue' });
        }
    }
    else if (href === '#') {
        $(obj).css({ 'font-weight': 'normal', 'color': 'blue' });
    }
}

No comments:

Post a Comment