I encountered a problem while working on a project today. My a.jsp introduced b.jsp, and my c.jsp also introduced b.jsp. The style in b.jsp was dynamically changed according to the introduction (in Write js changes in a.jsp and c.jsp). I found a lot of codes online and tried many times, but to no avail. Later, I saw this code, document.getElementById("aa").style.cssText="background:#1175d9;"; (cssText="" you can add the style you need inside the quotes), which solved my problem.