I am a beginner in html and javascript. I am trying to output some text when a button is pressed, from javascript using .innerHTML but it doesn't print anything out. I am linking the div's by id(if it is possible I would like to avoid loops). Here's the code;
<section class="box special features">
<div class="features-row">
<section>
<h3 ="h31"> </h3>
<p id="p1"> </p>
<p id="p2"> </p>
</section>
<section id="s2">
<h3 id="h32"> </h3>
<p id="p3"> </p>
<p id="p4"> </p>
</section>
</div>
</section>
<button onclick= "myFunction()" id="button" name="button">ok</button>
<script type="text/javascript">
function myFunction () {
h31.innerHTML = ("some text 1");
p1.innerHTML = ("some text 2");
p2.innerHTML = ("some text 3");
h32.innerHTML = ("some text 4");
p3.innerHTML = ("some text 5");
p4.innerHTML = ("some text 4");
}
</script>
Thank you.
` typo present in your actual code?
– Frédéric Hamidi Mar 21 '16 at 14:42