jquery removeClass() method


  Translation results:

remove

UK[rɪˈmu:v] US[rɪˈmuv]

vt.Remove; expel; take off, take off; migrate

vi. Migrate, move; leave

n.Distance, gap; move

class

英[klɑ:s] 美[klæs]

n.Class; class; grade; category

vt. Classify… into a certain level, treat… as (or classify, classify); put… into a certain class

adj. Very good, excellent, outstanding

vi. Belong to... category (or level), be listed as a certain category (or level)

jquery removeClass() methodsyntax

Function: removeClass() method removes one or more classes from the selected element. If no parameters are specified, this method will remove all classes from the selected elements.

Syntax: $(selector).removeClass(class)

Parameters:

ParameterDescription
class Optional. Specifies the name of the class to be removed. To remove several classes, use spaces to separate class names. If this parameter is not set, all classes will be removed.

#Use functions to remove classes: Use functions to remove classes from selected elements.

Syntax: $(selector).removeClass(function(index,oldclass))

##Parameters:

ParametersDescriptionfunction(index,oldclass) Required. Removes the specified class by running the function. index Optional. Accepts the index position of the selector. html Optional. Accepts the old class value of the selector.

jquery removeClass() methodexample

<html>
<head>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("button").click(function(){
    $("p").removeClass("intro");
  });
});
</script>
<style type="text/css">
.intro
{
font-size:120%;
color:red;
}
</style>
</head>

<body>
<h1 id="h1">This is a heading</h1>
<p class="intro">This is a paragraph.</p>
<p>This is another paragraph.</p>
<button>从第一个段落中删除类</button>
</body>
</html>
Run instance »

Click the "Run instance" button to view the online instance