javascript - Issue in rewriting scripts to be vanilla js (not jQuery) -


I'm rewriting my Chrome extension in the vanilla code instead of jQuery, and for the most part it's been easy is. How ever have I come in a part that does not work for purpose.

Basic jQuery-based code:

  $ (".file.flayer"). (Work () {// relevant code using "this"}});   

New vanilla-only code:

  var flairs = document.querySelectorAll (".flare" content); For (var i = 0; i & lt; flairs.length; i ++) {flairs [i] .addEventListener ("click", function (event) {// indispensable code using flairs [i] }); }   

This issue with vanilla code is that each click on .content .flair element is always flairs (i.e. Flares [flairs.length - 1] instead of flairs [i] . .

I can not squash this bug!

Thank you for your time.

The problem was with the closure. < See more with thanks for P> @ Arun-P-Johnny

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -