问题
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