Adding function parameters using a single variable in jQuery - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:click

Description

Adding function parameters using a single variable in jQuery

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.6.js"></script> 
  <script type="text/javascript">
    $(function(){//w  ww .  jav  a2 s  .  c  o  m
function Func (a,b){
 console.log(a+' | '+b);
}
var Parameters = 'abc,123';

var Function = Func;

$('button').click(function() {
    Func.apply(null, Parameters.split(","));
});

    });

      </script> 
 </head> 
 <body> 
  <button>Cool</button>  
 </body>
</html>

Related Tutorials