createElement is the concept of using the W3C DOM object model to create child nodes, that is, child elements in HTML
The code copy is as follows:
<script>
window.onload = function () {
var input = document.createElement('input');
var button = document.createElement('input');
input.type ='text';
input.id= 'text';
input.value ='1';
button.type='button';
button.value ='added by adding';
button.style.width = '40px';
button.style.height = '23px';
document.body.appendChild(input);
document.body.appendChild(button);
button.onclick = function(){
var value = input.value;
input.value = value * 1 + 1;
}
}
</script>
Note: value is actually a character. If you change input.value=value*1+1; to input.value=value+1; the result will appear 111111. It constantly adds 1 in the form of a character, so at this time the value*1 can convert the value value into Int type.
Summarize:
To ultimately solve the compatibility problem of the createElement method, you should still pay attention to judging the browser. For IE, you can use its unique method by passing a legitimate HTML code string as a parameter for createElement. Non-IE browsers still use the standard method of the W3C specification.