JS

 /*
* 字符串 分割成字符串数组 并动态添加到指定ID的DOM 里
* @id 要插入到DOM元素的ID
*
* 输入值为图片URL 字符串
* */
function addImages(id){
/*字符串 变量*/
var images='{$content.pictureurl} ' ;
/* console.log( images ) ;*/
/*字符串分割成字符串数组 split*/
var StringArray = images.split(',');
/* console.log( StringArray ) ;*/
/*遍历 字符串数组 并动态插入到DOM里*/
for(i=0,ii=StringArray.length;i<ii;i++){
/* console.log(StringArray.length);*/
var imageURL =StringArray[i];
/* console.log( imageURL);*/ var ele= document.getElementById(id);
/*叠加内容*/ ele .innerHTML+="<img class='lazy' data-original='' src="+'/'+imageURL+''+">";
} }
addImages("con");

随笔 JS 字符串 分割成字符串数组 并动态添加到指定ID的DOM 里的更多相关文章

  1. js 字符串分割成字符串数组 遍历数组插入指定DOM里 原生JS效果

    使用的TP3.2 JS字符串分割成字符串数组 var images='{$content.pictureurl} ' ;结构是这样 attachment/picture/uploadify/20141 ...

  2. split 将字符串分割成字符串数组

    list_name = list_name.split(","); split() 方法用于把一个字符串分割成字符串数组. 语法 stringObject.split(separa ...

  3. 【转载】C#中将字符串分割成字符数组

    在C#中字符串类型String是由一系列的单个字符组合而成,其实可以通过字符串String对象ToCharArray()方法来将字符串中的元素逐一存在数据类型为Char的一维数组中. 例如将字符str ...

  4. Swift - 将字符串拆分成数组(把一个字符串分割成字符串数组)

    在Swift中,如果需要把一个字符串根据特定的分隔符拆分(split)成字符串数组,通常有如下两种方法: 1,使用componentsSeparatedByString()方法 1 2 3 4 5 l ...

  5. javascript split() 把一个字符串分割成字符串数组,类似于PHP的 explode()函数

    用法类似于框里的 例子:

  6. oracle根据分隔符将字符串分割成数组函数

    --创建表类型 create or replace type mytype as table of number;--如果定义成varchar--CREATE OR REPLACE type myty ...

  7. shell 将字符串分割成数组

    代码:test.sh #!/bin/bash a="one,two,three,four" #要将$a分割开,可以这样: OLD_IFS="$IFS" IFS= ...

  8. Java中将字符串用空格分割成字符串数组的split方法

    官方文档链接:public String[] split(String regex) 本文以空格作为分割串. CaseOne import java.util.Scanner; public clas ...

  9. JS对象 字符串分割 split() 方法将字符串分割为字符串数组,并返回此数组。 语法: stringObject.split(separator,limit)

    字符串分割split() 知识讲解: split() 方法将字符串分割为字符串数组,并返回此数组. 语法: stringObject.split(separator,limit) 参数说明: 注意:如 ...

随机推荐

  1. mysql查询时间戳和日期的转换

    mysql提供了两个函数: from_unixtime(time_stamp) -> 将时间戳转换为日期 unix_timestamp(date) -> 将指定的日期或者日期字符串转换为时 ...

  2. CentOS6.5下搭建NFS文件服务器

    本文参考这里 CentOS下搭建NFS服务器总结 环境介绍: 1. 服务器: 192.168.0.100 2. 客户机: 192.168.0.101 安装软件包: 服务器和客户机都要安装nfs 和 r ...

  3. MVVM: 通过 x:Bind 实现 MVVM(不用 Command)

    背水一战 Windows 10 之 MVVM(Model-View-ViewModel) 通过 x:Bind 实现 MVVM(不用 Command) 示例1.ModelMVVM/Model/Produ ...

  4. Eclipse中使用SVN

    1.在Eclipse里下载Subclipse插件   方法一:从Eclipse Marketplace里面下载 具体操作:打开Eclipse --> Help --> Eclipse Ma ...

  5. Struts2+Spring+Mybatis+Junit 测试

    Struts2+Spring+Mybatis+Junit 测试 博客分类: HtmlUnit Junit Spring 测试 Mybatis  package com.action.kioskmoni ...

  6. js-JavaScript高级程序设计学习笔记9

    依然第十三章 事件 1.页面上的所有元素都支持鼠标事件,除了mouseenter和mouseleave,所有鼠标事件都会冒泡. 2.修改键:shift.ctrl.alt.meta.四个属性表示修改键的 ...

  7. Leetcode First Bad Version

    You are a product manager and currently leading a team to develop a new product. Unfortunately, the ...

  8. Leetcode 226. Invert Binary Tree

    Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 class Solution(object): ...

  9. 解析window.open链接的参数

    ); var arr = new Array(); arr = str.split("&"); ){ ; i<arr.length; i++){ ){ ); if(p ...

  10. C#皮肤制作

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; u ...