jquery - Modify css class with Javascript doesn't work -
I am currently writing a little chrome extension to modify an existing site. I try to modify a div element if the child has a specialty with value (for example red, blue, ...). If the child has a value with the attribute value red, then I want the original foot color in red.
I have removed this JS:
// find parent div element element = element.getElementsByClassName ("existing-category-to-find-div") [ 0]; // Check whether the child is blue from the specialty ... if (color == blue) {element.className + = "RedColorClass"; }
If I elemsent printout with element.outer HTML or className everything is fine and I'm seeing new value. But the actual site is still old value and it has not changed. Do I have to trigger something to refresh the html site?
Use element.classList .add ("RedColorClass")
or, If you use jQuery:
$ (element) .addClass ("RedColorClass");
Comments
Post a Comment