判斷單選框是否選中:
if ($(this).is(':checked')) { console.log('選中了'); }
或者:
if (this).prop('checked')==true) {
console.log('選中了,推薦用這個方法哦');
}
獲取單選框選中的值:
$("input[name=type]:checked").val()
判斷單選框是否選中:
if ($(this).is(':checked')) { console.log('選中了'); }
或者:
if (this).prop('checked')==true) {
console.log('選中了,推薦用這個方法哦');
}
$("input[name=type]:checked").val()