But it seems there no straight forward way such as static variable to do this.
Below sample javascript code can be used to achieve this.
function addCategory()
{
if ( typeof addCategory.no == 'undefined' )
addCategory.no =1;
else
addCategory.no =addCategory.no +1;
}
<input type=button onclick=”addCategory()”>
Explanation:
addCategory.no----->contains total number of times the addCategory() get invoked.
no----> is variable name. Here it acts as member variable for addCategroy() function.
addCategory---->is function name. Javascript treats every function as object. That’s why we are accessing variable as addCategory.no
More Articles...
1 comment:
Hello if you want to count number clicks on a button so you can use function count();
for example click here web analysis indore
Post a Comment