<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>111</title>
</head>
<body class="gray-bg">
<script src="js/jquery.min.js"></script>
<script type="text/javascript">
var devc=‘123,2345,45678,56789‘;
var sum = 0;
/*charCodeAt 获取逗号的编码*/
for(var i=0;i<devc.length;i++){
if(devc.charCodeAt(i) == ‘,‘.charCodeAt(0)){
sum++
}
}
console.log(sum) //3(求逗号的个数)
for(var i=0;i<devc.length;i++){
if(devc.charAt(i) == ‘,‘){
sum++
}
}
console.log(sum)//3
var str=devc.split(‘,‘).length;
console.log(str) //4
$.trim()是删除字符串开始和末尾的空格
console.log(tem);
console.log(typeof tem);
console.log(date);
console.log(typeof date);
var tem1=$.trim(tem);
var data9=$.trim(date);
</script>
</body>
</html>
原文地址:https://www.cnblogs.com/lsc-boke/p/10996937.html
时间: 2024-11-02 14:04:21