-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathindex.html
25 lines (25 loc) · 878 Bytes
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>去除字符串左右的空格</title>
<link rel="stylesheet" type="text/css" href="../../css/bootstrap.min.css" media="all"/>
<link rel="stylesheet" type="text/css" href="../../css/bootstrap-theme.min.css" media="all"/>
<link rel="stylesheet" type="text/css" href="../../css/reset.css" media="all"/>
</head>
<body>
<div class="demo1 tc">
<input class="input" type="text" value="[ 需要过滤的空格 ]" name="" id="input"/>
<button class="btn btn-primary" id="btn">过滤</button>
</div>
<script>
(function(){
var input = document.getElementById('input');
var btn = document.getElementById('btn');
btn.onclick = function(){
input.value = input.value.replace(/(\s|\u00A0)+|(\s|\u00A0)+/g,'');
}
}());
</script>
</body>
</html>