站內搜尋

Thursday, January 29, 2015

[JavaScript] 抓有相同 name 的 checkbox 被選取的值

var c = document.getElementsByName('mycheckbox[]');
var len = c.length;
for (var i=0; i<len; i++) {
if(c[i].checked) {
alert(c[i].value);
}
}

No comments:

Post a Comment