In the first ‘Try it Yourself” example of the w3 tutorials
( See: [url]https://www.w3schools.com/howto/howto_js_tabs.asp
The tab buttons are assigned an onclick function like this
[code]
<div class=”tab”>
<button class=”tablinks” onclick=”openCity(event, ‘London’)”>London</button>
<button class=”tablinks” onclick=”openCity(event, ‘Paris’)”>Paris</button>
<button class=”tablinks” onclick=”openCity(event, ‘Tokyo’)”>Tokyo</button>
</div>
I can not find a description of the ‘event’ attribute of the function
and I do not see it being used in the ‘openCity’ function being called.
[code]
function openCity(evt, cityName) {
// Declare all variables
var i, tabcontent, tablinks;
// Get all elements with class=”tabcontent” and hide them
tabcontent = document.getElementsByClassName(“tabcontent”);
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = “none”;
}
// Get all elements with class=”tablinks” and remove the class “active”
tablinks = document.getElementsByClassName(“tablinks”);
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(” active”, “”);
}
// Show the current tab, and add an “active” class to the button that opened the tab
document.getElementById(cityName).style.display = “block”;
evt.currentTarget.className += ” active”;
}
Could someone give me an explanation of how ‘event’ is being used by the function
or a reference that describes it use within the function?
Or how is is used elsewhere?
Does it relate somehow to the ‘this’ attributes of object functions?
?
I’m totally confused as to how it is being used in a function that does not seem to use it!