transfer data in functions ? Javascript [closed]

You need to specify the parameter/argument to the test() function.

$('#element').click(function(){
  test(somedata);
});

function test(arg1){
   alert(arg1);
}

Take a look at Function MDN document.

Leave a Comment