HTML은 요소를 켜거나 끄는 버튼 목록입니다.
버튼의 텍스트를 "표시"에서 "숨기기"로 변경하고 싶습니다. complete()
콜백 을 사용하여 완료되기를 바랍니다 . 클릭 한 요소에 어떻게 액세스 할 수 있습니까?
이 JS 코드가 있습니다.
$("body").on("click", ".selector", function(eve) {
$(".selector", $(this).parent()).toggle(function(){
$(/*here comes the element that was clicked*/).text(
function(i,text){
return text == "show" ? "hide" : "show";
}
);
});
});
참조 저장 this
$("body").on("click", ".selector", function(eve) {
var that = $(this);
$(".selector", $(this).parent()).toggle(function(){
that.text(
function(i,text){
return text == "show" ? "hide" : "show";
}
);
});
});
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다