UPDATE: .call function works, thanks for the quick replies :) Tested the other solution suggested too and
So I have this code, function setAttribute which takes four inputs and then applies them using this. The long code where it does
this.setAttribute("data-index-all", 1); works, but when I made it into a function it doesn't. I'm pretty sure that the problem is with "this" in a function. If someone could point out what's wrong I'd be very thankful.
function setAttribute(a, b, c, d){
this.setAttribute("data-index-all", a);
this.setAttribute("data-index-uleval", b);
this.setAttribute("data-index-vasakul", c);
this.setAttribute("data-index-paremal", d);
}
if (!flipped) {
setAttribute(1, 0, 1, 0);
}else{
setAttribute(0, 1, 0, 1);
}
if (!flipped) {
this.setAttribute("data-index-all", 1);
this.setAttribute("data-index-uleval", 0);
this.setAttribute("data-index-vasakul", 1);
this.setAttribute("data-index-paremal", 0);
} else {
this.setAttribute("data-index-all", 0);
this.setAttribute("data-index-uleval", 1);
this.setAttribute("data-index-vasakul", 0);
this.setAttribute("data-index-paremal", 1);
}