문제가 있습니다. 링크 p를 클릭하고 다른 링크를 클릭하면 작동하지 않습니다. 다시 클릭하면 작동합니다.JQuery 토글() 함수
이 내 jQuery 코드입니다 : 나는 그것을 할 수있는 방법의 초기 값은 0이어야한다 다른 링크를 클릭하면
var toggle = 0;
$(document).ready(function() {
$(".feedback_block").each(function() {
$("a", this).click(function (e) {
if (toggle == 0) {
$(this).parent().children("p").stop(true, true).fadeIn(500);
$(this).addClass("clicked");
$(this).children().addClass("clicked_span");
toggle = 1;
console.log(toggle);
} else
if (toggle == 1) {
$(this).parent().children("p").stop(true, true).fadeOut(500);
$(this).removeClass("clicked");
$(this).children().removeClass("clicked_span");
toggle = 0;
console.log(toggle);
}
e.stopPropagation();
return false;
});
toggle = 0;
});
});
내가 매개 변수 토글 1
가져 오기를 클릭하고?
내 예 : http://jsfiddle.net/amkrtchyan/tjzaR/
나는 이것을 편집했지만 S/O 편집자는 약 10 건의 추천 도서를 거부했다. 누구든지 내 (향후) 편집을 개선하십시오. – halfer