Jump to content

MegaMech

Members
  • Content Count

    3
  • Joined

  • Last visited

Community Reputation

0 Neutral

About MegaMech

  • Rank
    Newbie
  1. I believe this ends in semantics. window.onload = () => { tabButtons[0].onclick = openCity(e, "London"); tabButtons[0].onclick = openCity(e, "York"); tabButtons[0].onclick = openCity(e, "Ontario"); } <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> My example in the previous post requires cleverness to open
  2. Certainly a strange approach to question its deprecation without looking it up yourself. Not only is the use of event deprecated, but it was never a standard in the first place. See: https://stackoverflow.com/questions/58341832/event-is-deprecated-what-should-be-used-instead Implementing 'this' in its place is a great alternative because it returns the element which is sufficient for the tutorial. That's outside the scope of the tutorial as the subject is not "how to use javascript events." Sometimes the simple solution is the best one and in this tutorial using the ht
  3. The how to make javascript tabs page is outdated and uses deprecated "event" in onclick. Consider altering to the following: function openCity(evt, cityName) { -> // e better explains that the required parameter is an element rather than an event (Or el, element, etc.). function openCity(e, cityName) { onclick="openCity(event, 'London') -> onclick="openCity(this, 'London') evt.currentTarget.className += " active"; -> e.className += " active"; https://www.w3schools.com/howto/howto_js_tabs.asp
×
×
  • Create New...