current position:Home>Two submit buttons call the judgment of the same onclick event

Two submit buttons call the judgment of the same onclick event

2022-02-04 17:20:23 CSDN Q & A

Now I form There are two of them submit, Examples are as follows :

1

<button type="submit" id="a2" name="_ActionID value="a2" onclick=" function ()">2

Two submit Called onclick The method is the same , Function, please js How to judge which one I clicked in the submit Well ? Function cannot take any arguments




Take the answer :

Function can add parameters , take this( Currently clicked button object ) Pass to function

function  function (el){alert(el.name)}<button type="submit" id="a2" name="_ActionID value="a2" onclick=" function (this)">

Help, please Adopt 【 This answer is in the upper right corner 】, thank you ~~ If you have other questions, you can continue to communicate ~



Other answers 2:

hold id Value as js The parameters of the function are passed into the function .


Other answers 3:

The answer code of your question is as follows :( If help , Hope to adopt ! thank you ! Click on the... At the top right of my answer 【 Adopt 】 Button )

<script>function  function (){ var e = arguments.callee.caller.arguments[0] || window.event; alert(e.srcElement.value);}</script><button type="submit" id="a1" name="_ActionID" value="a1" onclick=" function ()">A1</button><button type="submit" id="a2" name="_ActionID" value="a2" onclick=" function ()">A2</button>

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/02/202202041720216191.html

Random recommended