'See me'를 클릭하면 'see me see'라고 표시됩니다.
나는 이것을 $ ('div')로 할 수있다. ... 클릭하면 잘 작동한다. 하지만 컨테이너 div를 사용하는 것이 더 바람직하다고 생각합니다. 전체 페이지가 긴 페이지이고 함수가 onclick에 대해 div를 사용하면 클릭 만하면 실행됩니다.Jquery div 클래스를 Onclick div로 내부 div에서 클릭하면 표시
<div class="directFilter">
<div class="boxWithRightArrow seeMe">See me</div>
<div class="boldFont filterHeader">Sort By</div>
<div class="boxWithRightArrow borderTop bestClick">Best click</div>
<div class="boxWithRightArrow intermediateTime">Intermediate time</div>
<div class="boxWithRightArrow shortestTime">Shortest time</div>
<div class="boxWithRightArrow iPreferred">I preferred</div>
</div>
$('.directFilter').click(function() {
alert($(this).attr('class')); //alerts directFilter
if ($(this).hasClass("seeMe")) {
alert("see me");
} else if ($(this).hasClass("bestClick")) {
alert("b click");
} else if ($(this).hasClass("intermediateTime")) {
alert("itime");
} else if ($(this).hasClass("shortestTime")) {
alert("s time");
} else if ($(this).hasClass("iPreferred")) {
alert("i pre");
}
}
);
JsFiddle : http://jsfiddle.net/smilyface/e2L7s/
어떤 제안?
좋아! 잘 작동합니다. 감사합니다 :) 8 분 후에 만 답변으로 설정할 수 있습니다 (틱 마크)! – smilyface
이것은 내가 원한 것이다 : alert ($ (event.target) .hasClass ('seeMe')); – smilyface
그러면 다른 조건은 어떻습니까? – Adil