div 내의 특정 클래스를 클릭 할 때 무언가를 트리거하고 싶습니다.
나는 이것을 시도했다
$("div .event").click(function() {
alert($( this ).text());
});
과
$("div").on("click", $('.event'), function() {
alert($( this ).text());
});
//Or
$(".SimpleCalendar .event").click(function() {
alert($( this ).text());
});
//I do not even know what this is supposed to do ...
$(".SimpleCalendar tbody tr td div .event").click(function() {
alert($( this ).text());
});
그리고 더 많은 것들이 여전히 이것이 작동하지 않는 이유를 알 수 없습니다.
은 div
당신 것이있는 거 선택 클래스가있는 하나 .event
가 아니라 그것의 후손. 따라서 올바른 선택자는입니다 div.event
. 이 시도:
$("div.event").click(function() {
alert($( this ).text());
});
아니면 그냥 :
//Warning: if elements unlike the div also have the event class then stick to
//the above as the selector is more specific
$(".event").click(function() {
alert($( this ).text());
});
그리고 이러한 각 옵션은 다음과 같이 DOM에 준비되어 있어야합니다.
$(function() {
$("div.event").click(function() {
alert($( this ).text());
});
});
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다