1

I want to disable class automatically applied on div.

<div class="A B">

I want to disable Class 'A' but not 'B'. How could I do that ?

Quinn Wilson
  • 7,665
  • 1
  • 21
  • 30
Enigma
  • 701
  • 1
  • 13
  • 33

5 Answers5

11

I think you are looking for CSS that says. Don't listen to class A.

Alas, there is no such CSS.

  • Either you have to remove the class A from your source code.
  • Or you remove the class from the DOM by means of JavaScript.
  • Or you must overwrite your CSS in class B that any value that was set in class A gets initial/neutral values (sometimes it's the value 'initial', sometimes its the value 'auto' or 'none')
yunzen
  • 31,553
  • 11
  • 69
  • 98
4

You are probably looking for a javascript...

Add a id to your div and use

<div id="whatever" class="A B"></div>

<script type="text/javascript">
    window.document.onload = function(){ 
        document.getElementById("whatever").className = "A";
    }     
</script>
daker
  • 3,243
  • 3
  • 38
  • 52
0

I think that I accomplished succesefully. :)

For example I have my html code :

<a class="m2" href="#">Some text here, with bold</a>
<a class="m2 nobold" href="#">Some text here, without bold</a>

I use CSS for the first text

.m2 {
    font-weight: bold;
}

And for disable it, I use

.nobold {
font-weight: normal;
}

And it apply both, but you can change settings from the other CSS class ...

0

If you want to do this in straight js, give the div an ID:

<div id="myDiv" class="A B"></div>

And then in js:

document.getElementById("myDiv").classList.remove("B");
0

This code will act magically....

<script type='text/javascript'>
        jQuery(document).ready(function ($) {
        $( "div" ).removeClass( 'your_class_name' );
      });
</script>