jquery remove class

前端 未结 4 2029
礼貌的吻别
礼貌的吻别 2021-01-21 00:12

i got a class,

div.domtab div{
        clear:both;
        width:auto;
        background:#eee;
        color:#000;
        padding:1em 1.5em;
    }


        
相关标签:
4条回答
  • 2021-01-21 00:39

    The reason the above answers are correct, is because this method specifies "Class" in it's name, implying that it is ASSUMED you are giving it a valid class name. Being as "." implies a class, this becomes a redundancy.

    Thus, when using "removeClass" a "." should not be used.

    0 讨论(0)
  • 2021-01-21 00:42

    You just missed out the line that is actually correct.

    $('#tag1').removeClass('domtab');
    

    The code above should do the trick.

    0 讨论(0)
  • 2021-01-21 00:46

    Considering your markup is like:

    <div class="domtab">
      ...
      <div id="tag1"></div>
      ...
    </div>
    

    You can remove the class by

    $('#tag1').closest('.domtab').removeClass('domtab');

    0 讨论(0)
  • 2021-01-21 01:02

    try $('#tag1').removeClass('domtab');

    0 讨论(0)
提交回复
热议问题