javascript - can any one help me with this jquery code , i want to console the array out side the loop? -


 $('#list').click(function(){                         var val = [];                         $(':check box:checked').each(function(i){                             val[i] = $(this).val();                         });                         console.log(val);                      }); 

can 1 me jquery code , want console array out side loop !! tried many options ,no success ,please me

i want print array out side click function

as said in comment, need make val not local variable. can moving declaration outside of closure.

val = []; $('#list').click(function(){     val = [];     $(':checkbox:checked').each(function(i){         val[i] = $(this).val();     });     console.log(val);  }); 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -