Pure JavaScript version of jQuery each