在我的程序中,我一次顯示一個問題,然後點擊它發佈並獲得第二個問題。但在我申請的複選框列表中的一些邏輯jQuery的每一個問題,我這樣稱呼它如何唯一標識checkBox上的jQuery函數更改點擊?
$(document).ready(function() {
$("input:checkbox").change(function() {
var txt = $(this).parent().children("label").text();
if ($(this).is(':checked')) {
if ($(this).parent().children("label").text() == 'Not Sure') {
$("input:checkbox").attr('checked', false);
$("input:checkbox").attr('disabled', true);
$(this).attr('checked', true);
$(this).attr('disabled', false);
}
}
else {
if ($(this).parent().children("label").text() == 'Not Sure') {
$("input:checkbox").attr('checked', true);
$("input:checkbox").attr('disabled', false);
$(this).attr('checked', false);
}
}
});
$("input:checkbox").change(function() {
var txt = $(this).parent().children("label").text();
if ($(this).is(':checked')) {
if (txt == 'Not Sure' || txt == 'We Are Large Business' || txt == 'None of these apply') {
$("input:checkbox").attr('checked', false);
$("input:checkbox").attr('disabled', true);
$(this).attr('checked', true);
$(this).attr('disabled', false);
}
}
else {
if (txt == 'Not Sure' || txt == 'We Are Large Business' || txt == 'None of these apply') {
$("input:checkbox").attr('checked', false);
$("input:checkbox").attr('disabled', false);
$(this).attr('checked', false);
}
}
});
});
所以問題是,對於1個問題的邏輯是從其他複選框列表的問題和我不同需要調用相應的函數,如上面你在document.ready中看到的那樣有兩個函數。那麼如何解決一些特定的問題,我應該修復調用函數?