zoukankan      html  css  js  c++  java
  • 随笔 JS 字符串 分割成字符串数组 并动态添加到指定ID的DOM 里

    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");
  • 相关阅读:
    君の名は~ 观后感
    dp1,明天补题解
    【bzoj1222】[HNOI2001]产品加工
    Daily~Miracles
    luogu 1273有线电视网
    luogu 1373
    codeforces 721C
    codeforces 706E
    The~Best~Chanteur~宇多田ヒカル
    codeforces706D
  • 原文地址:https://www.cnblogs.com/xxx91hx/p/4174244.html
Copyright © 2011-2022 走看看