JSFiddle - React, Tailwind, and code Playground
by huuzoo
HTML
<input type="text" id="iptform" size="40" value="あああ,,いいい,ううう">
<input type="button" value="反映" onclick="alignText()">
<div id="result"></div>
CSS
p {
margin-top: 10px;
padding: 5px;
background-color: yellow;
}
JavaScript
function alignText () {
var ipt_form = document.getElementById('iptform') ;
var ipt_array = ipt_form.value.split(',');
var result_area = document.getElementById('result');
for (i = 0; i < ipt_array.length; i++ ) {
if (ipt_array[i] == '') continue; //←追加したコード
var element = document.createElement('p');
element.innerHTML = ipt_array[i];
result_area.appendChild(element);
}
}