@blog.justoneplanet.info

日々勉強

先頭に連番を振るJavaScript

勿体ないから・・・

function perform(){
    var txt = document.getElementById('input').value;
    var ary = txt.split('\n');
    for(var i = 0; i < ary.length; i++){
        ary[i] = (i + 1) + ',' + ary[i];
    }
    txt = ary.join('\n');
    document.getElementById('input').value = txt;
}

コメントはまだありません»

No comments yet.

RSS feed for comments on this post.TrackBack URL

Leave a comment