custom.html 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Custom Calendar - jQuery EasyUI Demo</title>
  6. <link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
  7. <link rel="stylesheet" type="text/css" href="../../themes/icon.css">
  8. <link rel="stylesheet" type="text/css" href="../demo.css">
  9. <script type="text/javascript" src="../../jquery.min.js"></script>
  10. <script type="text/javascript" src="../../jquery.easyui.min.js"></script>
  11. </head>
  12. <body>
  13. <h2>Custom Calendar</h2>
  14. <p>This example shows how to custom the calendar date by using 'formatter' function.</p>
  15. <div style="margin:20px 0"></div>
  16. <div class="easyui-calendar" style="width:250px;height:250px;" data-options="formatter:formatDay"></div>
  17. <script>
  18. var d1 = Math.floor((Math.random()*30)+1);
  19. var d2 = Math.floor((Math.random()*30)+1);
  20. function formatDay(date){
  21. var m = date.getMonth()+1;
  22. var d = date.getDate();
  23. var opts = $(this).calendar('options');
  24. if (opts.month == m && d == d1){
  25. return '<div class="icon-ok md">' + d + '</div>';
  26. } else if (opts.month == m && d == d2){
  27. return '<div class="icon-search md">' + d + '</div>';
  28. }
  29. return d;
  30. }
  31. </script>
  32. <style scoped="scoped">
  33. .md{
  34. height:16px;
  35. line-height:16px;
  36. background-position:2px center;
  37. text-align:right;
  38. font-weight:bold;
  39. padding:0 2px;
  40. color:red;
  41. }
  42. </style>
  43. </body>
  44. </html>