Hello. Started learning html / css. with js and $ almost not familiar) I wrote several forms and added an invisible submit button on each. how to make the button at the end of several forms click on each button and the data is sent to the server, the logic is elementary, but lack of syntax is a problem
I put one class on all submitters and thought that by clicking on the final button everything would be ok, but something went wrong) thanks in advance)
|
1 answer
To click there is a function click . With it, you can click on any item. There is also such an event on focus and so on.
JS Option:
function allClick() { var buttons = document.querySelectorAll('.button'); for(var i = 0; i < buttons.length; i++){ buttons[i].click(); }; }; <button class="button" onclick="console.log('ΠΠ½ΠΎΠΏΠΊΠ° 1')">ΠΠ½ΠΎΠΏΠΊΠ° 1</button> <button class="button" onclick="console.log('ΠΠ½ΠΎΠΏΠΊΠ° 2')">ΠΠ½ΠΎΠΏΠΊΠ° 2</button> <button class="button" onclick="console.log('ΠΠ½ΠΎΠΏΠΊΠ° 3')">ΠΠ½ΠΎΠΏΠΊΠ° 3</button> <p><button onclick="allClick()">ΠΠ°ΠΆΠ°ΡΡ Π½Π° Π²ΡΠ΅</button></p> JQuery option:
function allClick() { $('.button').click() }; <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <button class="button" onclick="console.log('ΠΠ½ΠΎΠΏΠΊΠ° 1')">ΠΠ½ΠΎΠΏΠΊΠ° 1</button> <button class="button" onclick="console.log('ΠΠ½ΠΎΠΏΠΊΠ° 2')">ΠΠ½ΠΎΠΏΠΊΠ° 2</button> <button class="button" onclick="console.log('ΠΠ½ΠΎΠΏΠΊΠ° 3')">ΠΠ½ΠΎΠΏΠΊΠ° 3</button> <p><button onclick="allClick()">ΠΠ°ΠΆΠ°ΡΡ Π½Π° Π²ΡΠ΅</button></p> - Yuri, thank you very much for your help) - Dmitry
|