Question Locked

Rewriting Javascript code to use 1 function instead of multiple

0 helpful
0 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

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%';}

0 replies

No replies were posted before this discussion closed.

This discussion is closed to new replies.