Rewriting Javascript code to use 1 function instead of multiple

By ·
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

<section id="ingredients" onmouseover="ingredientsHover()" onmouseout="ingredientsNormal()"> </section>

<section id="about" onmouseover="aboutHover()" onmouseout="aboutNormal()"></section>

<section id="preparation" onmouseover="preparationHover()" onmouseout="preparationNormal()"> </section>


function ingredientsHover(){
document.getElementById('ingredients') = "300%"

function ingredientsNormal(){
document.getElementById('ingredients') = "100%"

function preparationHover() {
document.getElementById('preparation') = '300%';

function preparationNormal() {
document.getElementById('preparation') = '100%';}

function aboutHover() {
document.getElementById('about') = '300%';

function aboutNormal() {
document.getElementById('about') = '100%';}

Thread display: Collapse - | Expand +

All Answers

Share your knowledge

Related Discussions

Related Forums