Jquery去除最后的字符例如var str = "abc,bcd,"; 要去掉最后的",",不能去掉两个字符串中间","
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "/TR/html4/loose.dtd"> <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>增加⽤户</title>
<script src="js/lib/jquery-1.9.0.js"></script>
<script type="text/javascript"
src="./static/jquery-json/jquery.json-2.4.min.js"></script>
<script type="text/javascript">
function deleteLastChar(str, c) {
var reg = new RegExp(c + "([^" + c + "]*?)$");
place(reg, function(w) {
if (w.length > 1) {
return w.substring(1);
} else {
return "";
}
});
}
function test() {
var tx = "abc,def,ghi,";
alert(deleteLastChar(tx, ","))
}
</script>
<body>
<div>
<input type="button" id="test" onClick="test();" />
</div>
</body>jquery字符串截取
</html>

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。