Home > Web Front-end > JS Tutorial > Specific steps on how to pass two parameters to the JS method in JS onclick

Specific steps on how to pass two parameters to the JS method in JS onclick

亚连
Release: 2018-05-17 10:25:31
Original
6696 people have browsed it

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
Copy after login

2.onclickPass parameters

<body>
  <button onclick=&#39;TestClick("1","2")&#39;/>//调用TestClick
函数
,把1传给a,把2传给b
</body>123
"<a href=&#39;
javascript
:void(0);&#39; onclick=\"showInfo(&#39;"+A+"&#39;,&#39;"+B+"&#39;)\"></a>1
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template