2

I have a weird problem and yet no solution was found. I am in need of changing a css-rule (say border-color) of a class with javaScript.

Let's think I have a bunch of div like this:

.patient{
  border: 1px solid blue;
  width: 100px;
  height:30px;
  margin:5px
}
.patient.active{
  border-color : red;
}
<div class="patient active"></div>
<div class="patient"></div>
<div class="patient"></div>
<div class="patient"></div>
<div class="patient"></div>

Now, the user should be able to change '.active' border-color in a way that whenever each div becomes active, it takes the new value as if I have changed the css rule in css file. When I set the border-color , it is added like a inline style to the selected div

Amir Shahbabaie
  • 1,352
  • 2
  • 14
  • 33
  • It's not a duplicate of mentioned above answer, but i think is incorrect question. Amir probably ask about the whole logic of making element `.active` – JSEvgeny Feb 12 '18 at 13:40
  • *change a css-rule of a class with javascript*? You can override it instead. Please share a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) – Ele Feb 12 '18 at 13:41
  • Can you please be more explanatory? – Pradeep Sambandam Feb 12 '18 at 13:55
  • Have a look at http://www.hunlock.com/blogs/Totally_Pwn_CSS_with_Javascript and https://developer.mozilla.org/en-US/docs/Web/API/CSS_Object_Model – Bergi Feb 12 '18 at 14:18
  • More coded added guys, unfortunately the more I search the less I find!! – Amir Shahbabaie Feb 12 '18 at 15:28

0 Answers0