Post archive

Tag: jquery checkbox

  • jQuery

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

    เช็กบ้อกมี attribute ตัวหนึ่งที่จะเป็นตัวบอกว่า ตัวมันเองถูกติ๊กเลือกหรือเปล่า คือ checked ถ้าหากว่าผู้ใช้ติ๊กเครื่องหมายถูก checked จะมีค่าเท่ากับ true ถ้าไม่ถูกเช็กจะมีค่าเท่ากับ false jQuery นั้นมีคำสั่งดึงค่าค่าจาก attribute ของคอนโทรลตัวไหนๆ ก็ตามง่ายๆ ดูตัวอย่าง Live Demo <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <title>jquery checkbox checked</title> <script type="text/javascript"> $(document).ready(function(){   $(‘#button’).click(function(){   alert( $(‘#checkbox’) .attr( ‘checked’ ) );   }); […]

    READ MORE