移動端日期插件Mobiscroll.js使用詳解
更新時間:2016年12月19日 10:12:53 作者:Zerone1993
這篇文章主要為大家詳細介紹了移動端日期插件Mobiscroll.js的使用方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下
mobiscroll js日期插件的基礎(chǔ)入門案例,移動端開發(fā)過程中可能會用到。
<html>
<head>
<meta charset="UTF-8">
<title>mobiscroll</title>
<link type="text/css" rel="stylesheet" href="../js/mobiscroll.custom-2.6.2.min.css" />
</head>
<body>
<!--mobiscroll會將表單控件的value屬性與插件的輸入值綁定-->
<input id="date" name="date" /><br />
<input id="time" name="time" /><br />
<input type="button" value="showTime" onclick="showTime()">
<!--一般將js腳本文件放在body元素的底部就是為了加快網(wǎng)頁的加載,因為網(wǎng)頁的加載和腳本的加載是分開的-->
<script src="../js/jquery-3.1.0.js"></script>
<script src="../js/mobiscroll.custom-2.6.2.min.js"></script>
<script>
//初始化日期控件
/** 日期控件 start */
var now = new Date();
var currYear = now.getFullYear();
var currMonth = now.getMonth() + 1;
var currDay = now.getDate();
//mobiScroll插件選項
var opt1 = {
preset : 'date', //日期,可選:date\datetime\time\tree_list\image_text\select
theme : 'android-ics light', //皮膚樣式,可選:default\android\android-ics light\android-ics\ios\jqm\sense-ui\wp light\wp
display : 'modal', //顯示方式 ,可選:modal\inline\bubble\top\bottom
mode : 'scroller', //日期選擇模式,可選:scroller\clickpick\mixed
lang : 'zh',
dateFormat : 'yyyy-mm-dd', // 面板日期格式
setText : '確認', //確認按鈕名稱
cancelText : '取消', //取消按鈕名籍我
dateOrder : 'yyyymmdd', //面板中日期排列格式
dayText : '日',
monthText : '月',
yearText : '年', //面板中年月日文字
showNow : false,
nowText : "今",
endYear: currYear +100, //結(jié)束年份
minDate: new Date(currYear, currMonth - 1, currDay+1),
onSelect:function(textVale,inst){ //選中時觸發(fā)事件
console.log("我被選中了.....");
},
onClose:function(textVale,inst){ //插件效果退出時執(zhí)行 inst:表示點擊的狀態(tài)反饋:set/cancel
console.log("textVale--"+textVale);
console.log(this.id);//this表示調(diào)用該插件的對象
}
};
//時間面板顯示日期
\$("#date").mobiscroll().date(opt1);
//面板顯示時間
\$("#time").mobiscroll().time(opt1);
function showTime(){
alert($('#date').val());
}
</script>
</body>
</html>

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
JavaScript實現(xiàn)內(nèi)容滾動與導(dǎo)航標(biāo)簽互動關(guān)聯(lián)方案
這篇文章主要介紹了JavaScript實現(xiàn)內(nèi)容滾動與導(dǎo)航標(biāo)簽互動關(guān)聯(lián)方案,主要根據(jù)滾動左側(cè)內(nèi)容,關(guān)聯(lián)激活右側(cè)導(dǎo)航節(jié)點展開相應(yīng)介紹,需要的小伙伴可以參考一下2022-06-06
JS實現(xiàn)將手機號中間的幾位數(shù)字變成****功能
這篇文章主要介紹了用js如何實現(xiàn)將手機號中間的幾位數(shù)字變成****?_,今天,我們要實現(xiàn)一個很常見并且簡單的功能如何將手機號中間的幾位數(shù)變成****,需要的朋友可以參考下2023-09-09

