0
我有幾分大約100課程,複選框有course-chkbox
類和我使用下面的代碼:混淆複選框檢查
//Make sure user has checked at least one course
if ($('.course-chkbox:checked').length === 0) {
alert('You have to have at least one course selected');
return false;
}
這是正確的基礎,我使用了最新版本的jQuery ?
有如何解決基於一些谷歌上搜索同樣的事情很多建議...
1. Usage of is("checked")
2. Usage of prop()
3. Looping through the elements involved and check each element if it's checked
什麼解決辦法是最好的,爲什麼?
我認爲你現在的解決方案是最好的。 – NoLifeKing