Reputation: 922
I want to hand over an id to a Javascript function as a parameter (inRef) and then process it with the protoype Fade.Effect. My function looks as follows:
<script type="text/javascript">
function fadeEffect(inRef) {
$(inRef).fade({ duration: 1.8, from: 0.7, to: 1 });
}
</script>
Firefox and Opera can handle it correctly, whereas Chrome and Safari throw a console error saying inRef is undefined. I hand over the inRef as a string and think Javascript needs it as something else (JSON?)
Thanks for any help.
Upvotes: 0
Views: 392
Reputation: 114417
inRef can be a string since $(inRef) turns it into an object reference. Perhaps the problem lies somewhere else. What happens if you use the literal instead of the variable?
$("divname").fade({ duration: 1.8, from: 0.7, to: 1 });
Upvotes: 0
Reputation: 55248
Inside the function alert(typeof inRef) to check whether inRef is cast as a string in webkit browsers.
function fadeEffect(inRef) {
alert(typeof inRef);
$(inRef).fade({ duration: 1.8, from: 0.7, to: 1 });
}
If its not, cast it as a string
function fadeEffect(inRef) {
$(inRef.toString()).fade({ duration: 1.8, from: 0.7, to: 1 });
}
Upvotes: 1