1. Menerapkan kode sumber
<! Doctype html> <!- Untuk mengubah header lisensi ini, pilih header lisensi di Project Properties. Untuk mengubah file template ini, pilih Tools | Templat dan buka templat di editor. -> <html> <head> <title> JavaScript mendapatkan hari terakhir bulan tertentu </itement> <meta charset = "utf-8"> <meta name = "viewport" content = "width = device-width"> <script type = "Text/JavaScript">/** mendapatkan hari terakhir pada bulan terakhir/tahun/tahun/tahun pertama/tahun. bulan tahun ini var tanggal = tanggal baru (tahun, bulan-1, '01 '); // atur tanggal.setDate (1); // atur tanggal bulan.setMonth (date.getMonth () + 1); // Dapatkan hari terakhir bulan ini cdate = tanggal baru (date.getTime () - 1000*60*60*24); // Cetak hari terakhir dari peringatan bulan tertentu (cdate.getlear ()+"tahun"+(angka (cdate.getMonth ())+1)+"Tanggal hari terakhir bulan itu:"+cdate.getDate ()+"hari"); // return hasil return cdate.getDate (); } </script> </head> <body> <input type = "Tombol" value = "Dapatkan hari terakhir bulan tertentu" ontClick = "getLastdayOfMonth (2014,6)"/> </body> </html>
2. Mencapai hasilnya