want to js every click, constantly add one node, the number of the text node of the node is one more than the number of the text node of the previous node, but how to increase the number of NAN, has used parseInt to convert the string into a number. Maybe the language description is not clear, the specific code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
*{
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<ul class="oUl">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
<input class="oBtn" type="button" value="">
</body>
<script>
var oBtn = document.getElementsByTagName("input")[0];
oBtn.onclick = append;
function append(){
var oUl = document.getElementsByTagName("ul")[0];
var cRlitextnode = parseInt(oUl.lastChild.textNode);
cRlitextnodePP;
console.log(cRlitextnode);
var li = document.createElement("li");
var textNode = document.createTextNode(cRlitextnode);
oUl.appendChild(li);
li.appendChild(textNode);
}
</script>
</html>
I hope you can help with the answer. Thank you.