How to get a string in h1 tag to js ?
<h1 id=q> hi </h1> <script type=text/JavaScript> var a=document.getelementbyid="q"; alert(a); </script>. how can I run this one without error.
. how can I run this one without error.","answerCount":5,"upvoteCount":1,"suggestedAnswer":[{"@type":"Answer","text":"no your code returns the element not the content\ndocument.getElementById(\"a\").innerHTML is the right\ndo that code\nactually innerHTML needs string","upvoteCount":4},{"@type":"Answer","text":"var h1Content = document.getElementById('q').innerHTML;\nalert(h1Content) ;","upvoteCount":1},{"@type":"Answer","text":"your id is not right. put \"\" around your id and then use it. \r\nalso there is an error in your script code. your line after script tag is wrong you can do it as\r\nlike following\r\n
<h1 id=q> hi </h1> <script type=text/JavaScript> var a=document.getelementbyid="q"; alert(a); </script>. how can I run this one without error.