从所有匹配的元素中删除全部或者指定的类:

  如果参数是callback,那么需要返回的是属性名,函数传参解释如下:

    1. index参数为对象在这个集合中的索引

    2. class参数为这个对象原先的class属性值

实例:

<!DOCTYPE html>
<html lang='zh-cn'>
<head>
<title>Insert you title</title>
<meta http-equiv='description' content='this is my page'>
<meta http-equiv='keywords' content='keyword1,keyword2,keyword3'>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- <script type='text/javascript' src='./js/jquery-3.0.0.js'></script> -->
<script type='text/javascript' src='./js/jquery-1.12.1.min.js'></script>
<style type='text/css'>
   input{font:400 13px/20px 'Courier New';color:#000;}
   .addOne{padding:0 8px;}
   .addTwo{color:#999;}
</style>
<script type='text/javascript'>
    $(function(){
        $('#user').removeClass(function(index,oldClass){
           console.log(oldClass);
           var reg = /\baddTwo\b/;
           return oldClass.replace(reg,'');
        });
    });
</script>
</head>
<body>
   <input type='text' id='user' required="required" value='user' class='addOne addTwo'/>
</body>
</html>

 

相关文章:

  • 2022-12-23
  • 2022-02-01
  • 2021-12-10
  • 2022-12-23
  • 2021-12-26
  • 2021-12-02
  • 2021-08-21
  • 2022-12-23
猜你喜欢
  • 2021-12-26
  • 2022-12-23
  • 2021-12-26
  • 2021-05-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案