字符串转数组、数组转字符串、给第一个单词色值

简介: 字符串转数组、数组转字符串、给第一个单词色值
<html>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<head>
<style>
</style>
<link rel=stylesheet href="style.css" type="text/css">
<script src="http://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script>
<style type="text/css">
  *{
    margin: 0;
    padding: 0;
  }
  body{
    font-size: 40px;
  }
  .title{
    display: none;
  }
  .nr{
    width: 519px;
    height: 195px;
    background-color: #ffffff;
    box-shadow: 1px 1px 15px 0px 
      rgba(0, 0, 0, 0.1);
    border-radius: 20px;
    margin: 0 auto;
  }
  span{
    display: block;
    width: 100%;
    height: 40px;
    line-height: 40px;
    text-align: center;
    font-weight: 800;
  }
  .word{
    padding-top: 27px;
    /* text-transform: capitalize; */
  }
</style>
</head>
<body>
<div class=title>L</div>
<div class=nr><span class=word>Lion</span>&nbsp;&nbsp;<span class=fanyi>狮子</span></div><br>
<div class=nr><span class=word>Log</span>&nbsp;&nbsp;<span class=fanyi>圆木</span></div><br>
</body>
<script type="text/javascript">
  $(".word").hide();
  var html = $(".word").html();
  var ss = html.split("");// 在每个逗号(,)处进行分解。
  console.log(ss)
  $(".word").html('');
  var spanBq = '<lable class style="margin-right:10px;color:#ff0000;">'+ ss[0] +'</lable>';
  $(".word").append(spanBq);
  var list = [];
  for (var i=0;i<ss.length;i++){
    console.log(ss[i],'273')
    if(i>0){
      var obj = ss[i]
      list.push(obj);
    }
  }
  console.log(list.toString().replace(/[\ |\~|\`|\!|\@|\#|\$|\%|\^|\&|\*|\(|\)|\-|\_|\+|\=|\||\\|\[|\]|\{|\}|\;|\:|\"|\'|\,|\<|\.|\>|\/|\?]/g,""),'273');
  var aa = list.toString().replace(/[\ |\~|\`|\!|\@|\#|\$|\%|\^|\&|\*|\(|\)|\-|\_|\+|\=|\||\\|\[|\]|\{|\}|\;|\:|\"|\'|\,|\<|\.|\>|\/|\?]/g,"");
  $(".word").append(aa);
  $(".word").show();
</script>
</html>

相关文章
|
12天前
|
索引 容器
06-数据容器str(字符串)-字符串的下标索引/字符串无法修改/查找字符串下标初始值/字符串的替换/字符串的分割/字符串去除前后空格/统计字符串的数量/字符串的循环遍历/对字符串进行分割
06-数据容器str(字符串)-字符串的下标索引/字符串无法修改/查找字符串下标初始值/字符串的替换/字符串的分割/字符串去除前后空格/统计字符串的数量/字符串的循环遍历/对字符串进行分割
|
3月前
|
算法
leetcode:387. 字符串中的第一个唯一字符
leetcode:387. 字符串中的第一个唯一字符
13 0
|
3月前
|
C++ 索引
字符串中的第一个唯一字符(C++)
字符串中的第一个唯一字符(C++)
24 0
|
4月前
字符和数组问题
字符和数组问题
|
8月前
|
JavaScript 前端开发 Java
数组转字符串( 字符串转数组~
数组转字符串可以使用不同的方法,具体取决于编程语言和上下文环境。以下是一些通用的示例:
|
9月前
|
JavaScript
常用的数组(字符串)方法有哪些?(一)
1.pop:末位删除,即删除数组的最后一项,返回值是被删除项。 2.shift:首位删除,即删除数组的第一项,返回值是被删除项。 3.splice:指定下标删除元素,返回被删除的元素。第一个参数是从下标几开始删除,第二个参数是删除几个,第三个参数是要插入的元素。splice方法是会改变原数组的。删除功能用的比较多,我个人更喜欢用filter来变相实现删除,splice是会改变原数组的,而filter不会
|
9月前
常用的数组(字符串)方法有哪些?(二)
concat:合并数组或者字符串,concat在项目中用的还是比较多的,最经典的就是一个表格数据是有两个或者三个数组组成的时候会用到,watch监听数组和concat结合使用。下期做一个例子。
|
9月前
常用的数组(字符串)方法有哪些?(三)
some:判断数组中有没有符合条件的元素,一个符合的都没有返回false,有一个就是true。
|
10月前
|
索引
字符串中的第一个唯一字符
字符串中的第一个唯一字符
48 0
|
JSON 数据格式
将字符串按指定的符号分割为集合或数组
将字符串按指定的符号分割为集合或数组
139 0
将字符串按指定的符号分割为集合或数组