jQuery javascript scoping problem -
I have the hidden input element that I use to give the names of the more input elements generated by javascript counter I am using as To get the counter value I use
parseInt ($ ('# counter'). Val ());
However, I use this code snippet several times in my code, so I thought it would be better to put it in the function
function getCounter () {ParseInt ($ ('# counter'). Val ()); }
It always undefines, while only the code snippet returns the correct value when running. It happens in many ways, which tried to throw the function as function inside $ 400 (function () {}), such as global function etc. How can I fix scoping?
Add "return" to your return statement :)
function GetCounter () {return parseInt ($ ('counter') ()).}
Comments
Post a Comment