Remove classname from element with javascript

前端 未结 4 2009
忘掉有多难
忘掉有多难 2020-12-24 07:35

I found the following regex from another Stack Overflow question: Change an element's class with JavaScript

And have used it in part of my script with success, h

4条回答
  •  攒了一身酷
    2020-12-24 08:32

    foo.className = foo.className.replace( /(?:^|\s)bar(?!\S)/ , '' );
    

    or with jQuery (which you seem to be using):

    foo.removeClass( 'bar' );
    

提交回复
热议问题