Use a “closure”:
$(edit_link).click(function(){ return changeViewMode(myvar); });
This creates an anonymous temporary function wrapper that knows about the parameter and passes it to the actual callback implementation.
Related Contents:
- Set a default parameter value for a JavaScript function
- How do JavaScript closures work?
- Pass an extra argument to a callback function
- JavaScript variable number of arguments to function
- Pass a JavaScript function as parameter
- Is there a better way to do optional function parameters in JavaScript? [duplicate]
- ES6 destructuring function parameter – naming root object
- JavaScript function aliasing doesn’t seem to work
- jQuery pass more parameters into callback
- Is it possible to get all arguments of a function as single object inside that function?
- In Javascript/jQuery what does (e) mean?
- Multiple arguments vs. options object
- What happens if I call a JS method with more parameters than it is defined to accept?
- What happens if I call a function with more arguments than it is defined to accept?
- Javascript function challenge add(1,2) and add(1)(2) both should return 3
- Pass only the second argument in javascript
- var functionName = function() {} vs function functionName() {}
- Why use named function expressions?
- Are “(function ( ) { } ) ( )” and “(function ( ) { } ( ) )” functionally equal in JavaScript? [duplicate]
- Please explain the use of JavaScript closures in loops [duplicate]
- Function declarations inside if/else statements?
- How to add an object to an array
- How can I convert the “arguments” object to an array in JavaScript?
- Javascript Closures and ‘this’
- Cannot read property ‘addEventListener’ of null
- this inside function
- The invocation context (this) of the forEach function call
- About closure, LexicalEnvironment and GC
- Proper use of const for defining functions
- setTimeout() inside JavaScript Class using “this”
- JavaScript: Get Argument Value and NAME of Passed Variable [duplicate]
- Why pass parameters to CSS and JavaScript link files like src=”../cnt.js?ver=4.0″?
- What happens when JavaScript variable name and function name is the same?
- How to make chainable function in JavaScript?
- How to use setInterval function within for loop
- How to create javascript delay function [duplicate]
- javascript closure immediate evaluation [duplicate]
- How To Solve The React Hook Closure Issue?
- Where should functions in function components go?
- Can you write nested functions in JavaScript?
- Can you alter a Javascript function after declaring it?
- Calling a Function defined inside another function in Javascript
- How does the location of a script tag in a page affect a JavaScript function that is defined in it?
- How to calculate an angle from points?
- setTimeout not working inside forEach
- javascript click event handler fires without clicking
- How are local variables referenced in closures? [duplicate]
- Function and Object Javascript
- Lexical environment and function scope
- Why can’t I use a Javascript function before its definition inside a try block?