This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
Should I pass an element object to a function or just the element id? I ask because I am having trouble getting the following to work (I'm trying to write a function that will either fade or display a div)...
The original function call is
When I run this code I get this error, "missing ] after element list" (in my example its line 5). When I pass in an element object instead of an element name I get this error, "el.style is undefined". Obviously I'm doing something wrong since neither one of them work, but if you could tell me which way is the "better" way or if it really doesn't matter. Thanks in advance.
so that means you are missing quotes around your string.
Better solution is to use a closure
Reason why a closure is better is you do not have to worry about quotes. The main reason you get better performance. When you use a string, the string needs to be evalutated. When you pass in a function reference, there is no evaluation step.