javascript - How to pass a 'constant' parameter in jquery -


I have a div element attached to it, which detects that a user right clicks and calls a function Functionality .

  $ ('# box_' + i) .bund ('mousudown', function (e) {if (e.which == 3) function, i)});   

The code is moved inside a loop (where i variable increases), because there are many divs that require correct click functionality on the page. However when it is called function , it always gets the last value of i instead of that value, when it was tied (). Is there a way to make it continuous, so the

i should not be changed to run the loop of the previous divs?

You get the value of i in a local area inside your loop To do this:

  // start your loop (function (i) {$ ('# box_' + i) .bund ('moushudown', function (e) {if (e .hig == 3) function (e, i)});}) (i); // End your loop    

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -