Es gibt insgesamt 5 Schaltflächen.
Hier ist mein Javascript:
Code: Select all
const choices = document.getElementsByClassName("choices");
const title = document.querySelector(".mainInfo h2");
const paragraph = document.querySelector(".mainInfo p");
class aboutUs{
constructor(title, paragraph){
this.title = title;
this.paragraph = paragraph;
}
}
let history = new aboutUs("Our History", "As a company we thr");
let goals = new aboutUs("Our Goals", "Our goals are as follows");
let team = new aboutUs("Our Team", "Our Team consists of");
let values = new aboutUs("Our Values", "The values we protect here at 45 Degrees are");
let why = new aboutUs("Why", "The Why is one of our favorite things to talk about");
let arr = [history, goals, team, values, why]
Array.from(choices).forEach(element =>{
element.onclick = function(){
console.log(element)
// title.textContent = arr[element].title;
// paragraph.textContent = arr[element].paragraph;
}
})
Mobile version