코드
- html
<ul class="newAry">
<li>첫번째 문자</li>
<li>두번째 문자</li>
<li>세번째 문자</li>
<li>네번째 문자</li>
<li>다섯번째 문자</li>
</ul>
- script 1
var txt = $('.newAry').text();
var newAry = txt.trim().replace(/\n/g, '/').replace(/\s/g,'').split('/');
console.log(newAry);
- script 2
$('.newAry').each(function(){
var $item = $(this).find('li');
var newAry = $item.map(function(){
return $(this).text();
});
console.log(newAry);
});
- script 3
var newAry = new Array();
var aryIdx = -1;
$('.newAry li').each(function(){
var txt = $(this).text();
aryIdx ++;
newAry[aryIdx] = txt;
});
console.log(newAry);