와 특정 클래스를 타겟팅 - Find checkboxes that are checked with a specific class이 질문의 연속으로 .find
는이 jQuery로 동일한 기능을 수행 할 수 있는가 - 나는 단지 구체적으로 "올바른"클래스와 체크 박스의 입력을 대상으로 지정할?
jQuery(function($) {
$(document).ready(function() {
$("input[type=checkbox]").click(function (e) {
if ($(e.currentTarget).closest("div.question").length > 0) {
toggleInputs($(e.currentTarget).closest("div.question")[0]);
}
});
});
function toggleInputs(questionElement) {
if ($(questionElement).data('max-answers') == undefined) {
return true;
} else {
maxAnswers = parseInt($(questionElement).data('max-answers'), 10);
if ($(questionElement).find(":checked").length >= maxAnswers) {
$(questionElement).find(":not(:checked)").attr("disabled", true);
} else {
$(questionElement).find("input[type=checkbox]").attr("disabled", false);
}
}
}
});
난 당신이 요구하는지 이해가 안 돼요. 클래스의 selector는 가장 일반적인/기본 jQuery 선택기 중 하나입니다. 단지'.correct'가 될 것입니다. 어디서 추가 하시겠습니까? 너 뭐 의심 스럽니? – drquicksilver