Question
August 24, 2020 at 09:37 PM
paulg.ie

Rewriting Javascript code to use 1 function instead of multiple

by paulg.ie . Updated 5 years, 12 months ago

Hello
Apologies i am very new to this. I am looking to rewrite the javascript code below in such a way that i only use 1 function instead of six to modify the font sizes. can anybody help me with that. the code is written in the index.html file

function ingredientsHover(){
document.getElementById(‘ingredients’).firstElementChild.firstElementChild.style.fontSize = “300%”
}

function ingredientsNormal(){
document.getElementById(‘ingredients’).firstElementChild.firstElementChild.style.fontSize = “100%”
}

function preparationHover() {
document.getElementById(‘preparation’).firstElementChild.firstElementChild.style.fontSize = ‘300%’;
}

function preparationNormal() {
document.getElementById(‘preparation’).firstElementChild.firstElementChild.style.fontSize = ‘100%’;}

function aboutHover() {
document.getElementById(‘about’).firstElementChild.firstElementChild.style.fontSize = ‘300%’;
}

function aboutNormal() {
document.getElementById(‘about’).firstElementChild.firstElementChild.style.fontSize = ‘100%’;}

This discussion is locked

All Comments