0
4

5 に答える 5

1

最後にクリックされたリンクを変数に保持するのはどうですか?

$(function () {
    var lastClicked;
    $(".text").click(function () {
        $("#Content").html($(this).next(".text1").html());
        if (lastClicked != undefined) {
            $(lastClicked).css("color", "");
        }
        lastClicked = this;
        $(this).css("color", "yellow");
    });
});

ここでデモを確認してください。もちろん、色を から"yellow"に変更します"red"(デモの注目を集めるため、黄色を使用しました。

于 2013-08-16T21:29:34.537 に答える
1

これを使用できます:

$(function () {
    $(".text").click(function () {
        $("#Content").html($(this).next(".text1").html());
        $(".text").css("color", "");
        $(this).css("color", "red");
    });
});
于 2013-08-16T21:40:21.563 に答える
1

どうぞ:

$(function() {
  $(".text").click(function() {
   $('.text').css('color','');
   $(this).css( "color", "red" );
   });
 });

http://jsfiddle.net/d7Nyu/

于 2013-08-16T21:32:52.117 に答える