Home >Web Front-end >JS Tutorial >Specific steps on how to pass two parameters to the JS method in JS onclick
Below I will compile for you the specific steps on how to pass two parameters to the JS method in JS onclick
Pass 2 parameters directly.
Example:
1. Define a jsmethod
<script> function TestClick(a,b){//定义了2个参数a,b }</script>1234
2.onclickPass parameters
<body> <button onclick='TestClick("1","2")'/>//调用TestClick 函数 ,把1传给a,把2传给b </body>123 "<a href=' javascript :void(0);' onclick=\"showInfo('"+A+"','"+B+"')\"></a>1
3. Pay attention to the single and double quotes
The above are the specific steps on how to pass two parameters to the JS method in JS onclick that I compiled for you. I hope it will be helpful to everyone in the future.
Related articles:
Detailed analysis and answers to js prototype chain inheritance and calling parent class methods
Rewriting of js methods Detailed explanation of overloading techniques
Focus on analysis of techniques for overriding the alert() method in JavaScript
The above is the detailed content of Specific steps on how to pass two parameters to the JS method in JS onclick. For more information, please follow other related articles on the PHP Chinese website!