javascriptpikaday

Pikaday - Multiple Inputs Vanilla JavaScript


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


Solution

  • 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] });
        }
    }