Изменить метку на основе видимости элемента (jQuery) - PullRequest
1 голос
/ 25 января 2010

HTML:

<a href="#">Show next element</a>
<div>content</div>

JQuery:

$('a').toggle(function () {
    $(this).next().show();
},
function () {
    $(this).next().hide();
});

Как изменить вышеупомянутый jQuery, чтобы он также изменял «Показать» в ссылке на «Скрыть», когда элемент виден?

Спасибо!

Ответы [ 2 ]

1 голос
/ 25 января 2010

Не проверено ...

$('a').toggle(function () {
    $(this).next().show();
    $(this).html("Hide next element");
},
function () {
    $(this).next().hide();
    $(this).html("Show next element");
});
0 голосов
/ 25 января 2010
$('a').toggle(function () {

    $(this).next().show();
    $(this).html('Hide next element');
},
function () {
    $(this).next().hide();
    $(this).html('Show next element');
});
...