Is it possible to select one of those 3 buttons with a URL link? I open the link and one of the buttons is already clicked.
Do I require to add a specific script?
<button id="uno" class="tablinks" onclick="openCity(event, '1')">
one
</button>
<button id="dos" class="tablinks" onclick="openCity(event, '2')">
two
</button>
<button id="tres" class="tablinks" onclick="openCity(event, '3')">
three
</button>
Yes, it is possible. Are you sure you want to emit a button click or do you just want to invoke openCity with some arguments? If so, in your JavaScript, you can write:
window.onload = function() {
openCity(3);
}
function openCity(buttonNum) {
console.log(buttonNum); // '3'
}
If you want to emit a button click, you can try:
window.onload = function() {
const buttons = document.querySelectorAll('.tablinks');
const firstButton = Array.from(buttons)[0];
firstButton.click();
}