I want to create some textfield by script,but how can I add some text between the textfield? I try to use "document.write" but it clear the page.
inform = document.getElementById('addinput');
newinput = document.createElement('input');
newinput.type = "text";
newinput.name = "NumA" + i;
newinput.id = "NumA" + i;
newinput.value = a;
inform.appendChild(newinput);
add = document.write('+');
inform.appendChild(add);
newinput = document.createElement('input');
newinput.type = "text";
newinput.name = "NumB" + i;
newinput.id = "NumB" + i;
newinput.value = b;
inform.appendChild(newinput);
Well you can create a span or paragraph element and use that to hold your text inbetween the two text boxes:
inform = document.getElementById('addinput');
newinput = document.createElement('input');
newinput.type = "text";
newinput.name = "NumA" + i;
newinput.id = "NumA" + i;
newinput.value = a;
inform.appendChild(newinput);
add = document.createElement('span');
add.innerHTML = "+";
inform.appendChild(add);
inform.appendChild(add);
newinput = document.createElement('input');
newinput.type = "text";
newinput.name = "NumB" + i;
newinput.id = "NumB" + i;
newinput.value = b;
inform.appendChild(newinput);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.