0

What I try to do is creating an overal(global) function which changes styling of different elements.

I will give you an example to clear out my question, I have multiple functions which changes elements indivually like this below for exmaple:

function changeBgColor(background) {
 exitIntentWrapper.style.background = background.value;
}

Which looks in the html like this:

onchange="changeStyling(this)"

What I tried is this:

function changeStyling(input, changeSelector, elementsCssChange) {
  console.log(input.value, changeSelector, elementsCssChange);

  changeSelector.style.elementCssChange= input.value;
}

onchange="changeStyling(this, exitIntentWrapper, backgroundColor)"

But how do I pass the elementsCssChange in this html onchange function.

What it logs now is that the following:

Uncaught ReferenceError: backgroundColor is not defined

Could someone help me out on this?

Sireini
  • 4,142
  • 12
  • 52
  • 91

0 Answers0