Question:

How do I set an html button to do something like display text or show an HTML document?

by Guest33768  |  earlier

0 LIKES UnLike

OK, I have the <button>lable</button> part but how do I set that lable button to display text(<p>text</p>) or display an HTML document. please give me the tags to do this and don't be smart.

 Tags:

   Report

1 ANSWERS


  1. Here&#039;s a simple example that should get you pointed in the right direction. Also, consider doing a Javascript tutorial.

    change the button element (&lt;button&gt;) to this: &lt;button onlick=&quot;doSomething()&quot;&gt;

    change your paragraph (&lt;p&gt;) to this: &lt;p id=&quot;textThingy&quot;&gt;

    add this in the &quot;head&quot; element:

    &lt;script type=&quot;text/javascript&quot;&gt;

        function doSomething() {

            var textThingyObject;

            textThingyObject = document.getElementById(&quot;textThingy&quot;);

            textThingy.innerText = &quot;So&#039;s yer face!&quot;;  //Whatever you want in here...

        }

    &lt;/script&gt;

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.
Unanswered Questions