Is it possible to fit several values into 1 line at once? Ex: getElementsByClassName ('any') [0,1]
In the example below, an alert is made, by pressing the upper letter, but I would like the same two-letter action to be performed by one line of code.
And if it is possible, after that, make it so that this function is executed only once on the started page, i.e. later to work as one-time only after reloading the page. 
(function () { $('#f, #p').addClass('testing'); var test = document.getElementsByClassName('testing')[0]; test.onclick = function () { alert('232'); }; }()); .main { text-align: center; font-size: 7em; } <div class="main"> <a id="f">F.</a><br> <a id="p">P.</a><br> </div> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>