วันพฤหัสบดีที่ 22 กันยายน พ.ศ. 2554

วิธีการตรวจสอบ checkbox หรือ selector ด้วย jQuery

http://api.jquery.com/checked-selector/

// รีเทิน เป็น true หรือ false $('#button').click(function(){ alert( $('#checkbox') .attr( 'checked' ) ); });


// รีเทิน เป็น value ของ checkbox หรือ selector $(":checked").val()

// ตรวจสบว่า แcheck id นั้น มีการ checked หรือไม่
rPrivacy=$('#Privacy2').attr('checked');
if (rPrivacy == 'checked') { if (parseInt(cRecip) ==0){ alert("Recipients is required."); return;}}

ไม่มีความคิดเห็น: