Pikaday - Multiple Inputs Vanilla JavaScript

穿精又带淫゛_ 提交于 2019-12-11 06:43:21

问题


I have tried to attach pikaday to multiple elements.

It seems like this is possible with the JQuery plugin.

Does anyone know if it is possible with Vanilla JS?

Here is the code:

http://bit.ly/IFM3De

Note: Will add it to the question once I have more information

Pikaday Plugin - https://github.com/dbushell/Pikaday


回答1:


You are using brackets. You need to use square braces to get a property of an object.

var eleGroup = document.querySelectorAll('.date-picker');

for(x in eleGroup) {
    if(eleGroup.hasOwnProperty(x)) {
        new Pikaday({ field: eleGroup[x] });
    }
}


来源:https://stackoverflow.com/questions/20333104/pikaday-multiple-inputs-vanilla-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!