I used getElementById method to return the tag's element but it returns the tag's type ?!
<!DOCTYPE html>
<html>
<head>
<title>Title</title>
</head>
<body>
<p id ="textlabel"></p>
<script>
function bonef(){
var a =
document.getElementById("textlabel");
var b = "1";
a.innerHTML = b;
}
</script>
<button onclick="bonef();">1</button>
</body>
</html>
It shows "[object HTMLParagraphElement]1" but I want "1" !
CodePudding user response:
Don't use getElementById any more, Instead use the querySelector:
let label = document.querySelector("#textlabel");
I think this is what you want to do:
function bonef(){
let a = document.querySelector("#textlabel")
a.innerHTML = "1";
}