2010-01-25 9 views
1

HTML :레이블 변경 (jQuery를)

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

jQuery를 요소가 보이면 숨기기?

감사합니다. 테스트되지 않았습니다

답변

1

은 ...

$('a').toggle(function() { 
    $(this).next().show(); 
    $(this).html("Hide next element"); 
}, 
function() { 
    $(this).next().hide(); 
    $(this).html("Show next element"); 
}); 
+0

나는 초 전에 그것을 생각. .text()가 더 좋지만 어쨌든 감사합니다! – 3zzy

+1

위대한 마음은 비슷하게 생각합니다 : D – alex

+0

@Nimbuz .text()는 HTML을 포함하지 않는 경우에만 해당됩니다. – alex

0
$('a').toggle(function() { 

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