1

メイン要素の1つ、または作業中のヘッダーのネストされたリストの1liつにリンクが見つかった場合、親要素を強調表示しようとしています。liJSは機能するはずですが、機能しません。正しい方向を向いていれば幸いです。

http://jsfiddle.net/fGGrf/

4

2 に答える 2

0

これはあなたが探しているものですか?

    $('.submenu-link').hover (function (e) {
        $(this).parent().parent().children('a').css('backgroundColor', 'red');
    }, function (e) {
        $(this).parent().parent().children('a').css('backgroundColor', 'white');
    });

JSFiddle::http://jsfiddle.net/fGGrf/5/

于 2012-05-31T15:17:03.737 に答える
0

これを試して:

$(document).ready(function(){
var dropdown = $('.dropdown');
var link= $('.submenu-link');

var cur = "www.domain.com/overview.php" // document.location.href ? document.location.href : document.location;
cur = cur.split('/' , -1);

    $('li a').each(function() {
        if ($(this).attr('href') == '/' + cur[1]) {
           $(this).parent().addClass('active');
        }
    })

});

http://jsfiddle.net/fGGrf/6/

于 2012-05-31T15:27:49.343 に答える