0
how can i get <p> tag value of html in JavaScript console?
i am trying to print the paragraph tag value 'hello' in html using JavaScript console. how can i do that? https://code.sololearn.com/WPE75Fhs2d63/?ref=app
3 Answers
+ 2
Add a onload event listener in which you call your function. Otherwise the functions runs before the HTML is loaded and the p element with id "h" can't be found by the JavaScript.
+ 2
Mr. 12 use the following code:
function myCal(){
return document.getElementById("h").innerHTML;
}
window.onload = () => {
console.log(myCal());
};
0
Aaron Eberhardt i didn't get it bro