Can you avoid repetition in such cases?
I try to avoid repetition in my code as much as possible. I know you can do this:
variable = variable+2
in that
variable += 2
but how can I avoid repetition here? Of course there is a way ...
this.className = this.className.replace("classname","")
+3
william malo
source
to share
3 answers
Unfortunately the answer is no, there are no abbreviations for this type of statement.
+3
DJ Quimby
source
to share
Make a function to do what you want? As for a = = I don't know how to overload operators in javascript ... see
Overloading arithmetic operators in JavaScript?
+1
Jared
source
to share
If you can use JQuery you can call
$(this).removeClass('classname');
0
Pascal Pichรฉ
source
to share