[ jquery 方法 removeClass([class|fn]) ] 此方法为每个匹配的元素删除指定的类名
从所有匹配的元素中删除全部或者指定的类:
如果参数是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>