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 1

    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