Question
-
Topic
-
Rewriting Javascript code to use 1 function instead of multiple
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 filefunction 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%';}