Home > Web Front-end > JS Tutorial > body text

How to use JS date time picker

php中世界最好的语言
Release: 2018-05-02 14:44:40
Original
1941 people have browsed it

This time I will show you how to use JS dateTime selector, what are the precautions when using JS date and time selector, the following is a practical case, let’s take a look .

Download Demo GitHub

flatpickr does not depend on any library. Smaller UI but lots of themes. A rich API and event system make it suitable for any environment. Available with webpack and as a jQuery plugin.

Installation

Install the flatpickr module

Use NPM to install the flatpickr module. Package management tool: https://www.npmjs.com/package/bower-npm-resolver

# using npm install
npm i flatpickr --save
Copy after login

Non-module environment

directly Import flatpickr file

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">
<script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
Copy after login

Usage

If you use webpack, you need to import flatpickr.

// commonjs
const flatpickr = require("flatpickr");
Copy after login
// 如果可用,推荐使用 es 模块
import flatpickr from "flatpickr";
Copy after login

The following are valid methods for creating flatpickr instances.

// 如果在框架中使用 flatpickr ,则建议直接传递该元素
flatpickr(element, {});
// 选择器也被支持
flatpickr("#myID", {});
// 创建多个实例
flatpickr(".anotherSelector");
Copy after login

Configuration is optional and passed in the object {}.

jQuery

If you use jQuery, flatpickr is available as a plugin.

$(".selector").flatpickr(optional_config);
Copy after login

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

How to operate Vue project packaging by environment

Detailed explanation of the steps to use dev-server in webpack

Detailed explanation of the use of slots/scoped in Vue

The above is the detailed content of How to use JS date time picker. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template