dotdotdot.js 中文特殊字符

来源:互联网 发布:美国mac电磁阀 编辑:程序博客网 时间:2024/05/16 01:38

dotdotdot.js 中文特殊字符


在使用jquery.dotdotdot.min.js插件时,你会发现如果文本是中文的特殊字符,此时就无法解析了,因为需要配置插件wap属性,如下代码:


<!DOCTYPE html>
<html lang="zh">
<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>
<style type="text/css">
#box{
width: 80px;
height: 50px;
border: 1px solid blueviolet;
}
</style>
<script src="src/jquery.min.js"></script>
<script src="src/jquery.dotdotdot.js"></script>
</head>
<body>
<textarea name="" rows="" cols="">

</textarea>
<button>获取</button>
<div id="box"></div>
<script>
$("button").click(function(){
$("#box").html($('textarea').val());
});

$("#box").dotdotdot({  
                   
wrap: 'letter' //注:中文必须改为letter  
        });  
</script>
</body>
</html>