<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div id="app">日期<span>shang</span><span>xia</span></div>
</body>
</html>
<script>
var str = document.querySelector("#app").innerHTML
console.log(str)
str=str.match(/[\u4e00-\u9fa5]/g).join("");
console.log(str)
</script>
JS 从字符串中提取出汉字方法
最新推荐文章于 2023-05-04 15:10:37 发布