本文实例讲述了javascript实现的淘宝旅行通用日历组件用法。分享给大家供大家参考。
在线演示:http://demo.jb51.net/js/2015/trip-calendar/demo.html
PS:下面的演示代码,需要用到 trip-calendar.js与trip-calendar.css文件。打包下载地址
具体如下:
<!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <meta name="author" content="angtian"> <meta name="description" content="淘宝旅行通用日历组件Demo1"> <meta name ="keywords" content="日历, 日历组件, 淘宝旅行日历"> <title>淘宝旅行通用日历组件Demo1</title> <style> body{padding:0;margin:0 10px;text-align:center;} .title{padding:0;margin:10px 0;font:700 18px/1.5 \5fae\8f6f\96c5\9ed1;} .title a{font:400 14px/1.5 Tahoma;margin-left:20px;} .example{margin-top:10px;} .example button{margin:0 5px 10px 0;} .calendar{display:inline-block;} </style> <script src="http://yui.yahooapis.com/3.5.1/build/yui/yui-min.js"></script> <script> var root = 'http://fgm.cc/learn/calendar/trip-calendar/'; YUI({ modules: { 'trip-calendar': { fullpath: root + 'trip-calendar.js', type : 'js', requires: ['trip-calendar-css'] }, 'trip-calendar-css': { fullpath: root + 'trip-calendar.css', type : 'css' } } }).use('trip-calendar', function(Y) { /** * 非弹出式日历实例 * 直接将日历插入到页面指定容器内 */ var oCal = new Y.TripCalendar({ container : '#J_Calendar', //非弹出式日历时指定的容器(必选) selectedDate: new Date //指定日历选择的日期 }); //日期点击事件 oCal.on('dateclick', function() { var selectedDate = this.get('selectedDate'); alert(selectedDate + '\u3010' + this.getDateInfo(selectedDate) + '\u3011'); }); Y.one('#J_Example').delegate('click', function(e) { var oTarget = e.currentTarget; value = oTarget.getAttribute('data-value'); switch(true) { //日历个数 case oTarget.hasClass('J_Count'): this.set('count', value).render(); break; //显示节假日 case oTarget.hasClass('J_showHoliday'): this.set('isHoliday', true).render(); break; //隐藏节假日 case oTarget.hasClass('J_hideHoliday'): this.set('isHoliday', false).render(); break; //时间范围限定 case oTarget.hasClass('J_Limit'): this.set('minDate', new Date) .set('maxDate', '') .set('afterDays', value) .set('date', new Date()); break; //指定初始日期 case oTarget.hasClass('J_InitDate'): this.set('minDate', value) .set('maxDate', '2012-12-21') .set('date', value); break; //下拉表单选择时间 case oTarget.hasClass('J_Select'): this.set('isSelect', true).render(); Y.all('.J_Count').slice(1).set('disabled', true); break; //取消下拉表单选择 case oTarget.hasClass('J_SelectOff'): this.set('isSelect', false).render(); Y.all('.J_Count').slice(1).set('disabled', false); break; } }, 'button', oCal); }); </script> </head> <body> <h1 id="淘宝旅行通用日历组件Demo-a-href-http-fgm-cc-learn-calendar-trip-calendar-Demo-html-Demo-a-a-href-http-fgm-cc-learn-calendar-trip-calendar-Demo-html-Demo-a-a-href-http-fgm-cc-learn-calendar-trip-calendar-Demo-html-Demo-a-a-href-http-fgm-cc-learn-calendar-trip-calendar-api-html-target-blank-API文档-a">淘宝旅行通用日历组件Demo1 <a href="http://fgm.cc/learn/calendar/trip-calendar/Demo1.html">Demo1</a><a href="http://fgm.cc/learn/calendar/trip-calendar/Demo2.html">Demo2</a><a href="http://fgm.cc/learn/calendar/trip-calendar/Demo3.html">Demo3</a><a href="http://fgm.cc/learn/calendar/trip-calendar/api.html" target="_blank">API文档</a></h1> <div id="J_Example" class="example"> <button class="J_Count" data-value="1">单日历</button> <button class="J_Count" data-value="2">双日历</button> <button class="J_Count" data-value="3">三日历</button> <button class="J_Count" data-value="4">四日历</button> <br /> <button class="J_showHoliday">显示节假日</button> <button class="J_hideHoliday">隐藏节假日</button> <br /> <button class="J_Limit" data-value="90">限定范围(今天->90天)</button> <button class="J_InitDate" data-value="2012-10-01">指定初始日期(2012年10月)</button> <button class="J_InitDate" data-value="">取消范围限定</button> <br /> <button class="J_Select">下拉表单选择时间</button> <button class="J_SelectOff">取消下拉表单选择</button> </div> <div id="J_Calendar" class="calendar"></div> </body> </html>
希望本文所述对大家的javascript程序设计有所帮助。

JavaScript核心數據類型在瀏覽器和Node.js中一致,但處理方式和額外類型有所不同。 1)全局對像在瀏覽器中為window,在Node.js中為global。 2)Node.js獨有Buffer對象,用於處理二進制數據。 3)性能和時間處理在兩者間也有差異,需根據環境調整代碼。

JavaScriptusestwotypesofcomments:single-line(//)andmulti-line(//).1)Use//forquicknotesorsingle-lineexplanations.2)Use//forlongerexplanationsorcommentingoutblocksofcode.Commentsshouldexplainthe'why',notthe'what',andbeplacedabovetherelevantcodeforclari

Python和JavaScript的主要區別在於類型系統和應用場景。 1.Python使用動態類型,適合科學計算和數據分析。 2.JavaScript採用弱類型,廣泛用於前端和全棧開發。兩者在異步編程和性能優化上各有優勢,選擇時應根據項目需求決定。

選擇Python還是JavaScript取決於項目類型:1)數據科學和自動化任務選擇Python;2)前端和全棧開發選擇JavaScript。 Python因其在數據處理和自動化方面的強大庫而備受青睞,而JavaScript則因其在網頁交互和全棧開發中的優勢而不可或缺。

Python和JavaScript各有優勢,選擇取決於項目需求和個人偏好。 1.Python易學,語法簡潔,適用於數據科學和後端開發,但執行速度較慢。 2.JavaScript在前端開發中無處不在,異步編程能力強,Node.js使其適用於全棧開發,但語法可能複雜且易出錯。

javascriptisnotbuiltoncorc; sanInterpretedlanguagethatrunsonenginesoftenwritteninc.1)JavascriptwasdesignedAsignedAsalightWeight,drackendedlanguageforwebbrowsers.2)Enginesevolvedfromsimpleterterpretpretpretpretpreterterpretpretpretpretpretpretpretpretpretcompilerers,典型地,替代品。

JavaScript可用於前端和後端開發。前端通過DOM操作增強用戶體驗,後端通過Node.js處理服務器任務。 1.前端示例:改變網頁文本內容。 2.後端示例:創建Node.js服務器。

選擇Python還是JavaScript應基於職業發展、學習曲線和生態系統:1)職業發展:Python適合數據科學和後端開發,JavaScript適合前端和全棧開發。 2)學習曲線:Python語法簡潔,適合初學者;JavaScript語法靈活。 3)生態系統:Python有豐富的科學計算庫,JavaScript有強大的前端框架。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

SecLists
SecLists是最終安全測試人員的伙伴。它是一個包含各種類型清單的集合,這些清單在安全評估過程中經常使用,而且都在一個地方。 SecLists透過方便地提供安全測試人員可能需要的所有列表,幫助提高安全測試的效率和生產力。清單類型包括使用者名稱、密碼、URL、模糊測試有效載荷、敏感資料模式、Web shell等等。測試人員只需將此儲存庫拉到新的測試機上,他就可以存取所需的每種類型的清單。

SublimeText3 英文版
推薦:為Win版本,支援程式碼提示!

SublimeText3 Linux新版
SublimeText3 Linux最新版

VSCode Windows 64位元 下載
微軟推出的免費、功能強大的一款IDE編輯器

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)