0

can i use this "elememt.className.replace(cl2,cl1)" Instead of this "element.className = elememt.className.replace(cl2,cl1)"

I want to replace a class with other class but when i wamt to do that with className.replace method i have to store it or assign it into element.className Like "element.className = elememt.className.replace(cl2,cl1)" but I want to write it directly like this "elememt.className.replace(cl2,cl1)" But it shows an error why it shows error can someone please explain

25th Apr 2021, 8:44 AM
Ahsan Tony
Ahsan Tony - avatar
3 Réponses
+ 1
Quoting from https://www.w3schools.com/jsref/jsref_replace.asp "Definition and Usage The replace() method searches a string for a specified value, or a regular expression, and returns a new string where the specified values are replaced." The method returns a modified copy of the calling object data.
25th Apr 2021, 1:27 PM
Ipang
+ 1
Ipang thanks bro
25th Apr 2021, 5:49 PM
Ahsan Tony
Ahsan Tony - avatar
0
Cool bro 👍👌
25th Apr 2021, 8:15 PM
Ipang