JavaScript Html/Javascript: Is it possible to set text style.display = “none” by default?

With the way I have my html and javascript set up right now, I have it so when the page loads up and shows up all the text under each button. You can click the button to hide and show the text right below it.

Is it possible to make it so all the text does NOT show up by default?

I was thinking you would have to make e.style.display = "none" by default but I'm not sure how/where to in this particular case.

<script type="text/javascript">

function toggleMe(a)
{
var e=document.getElementById(a);

if(!e)
{

return true;
}

if(e.style.display=="none")
{
e.style.display="block"
}
else
{
e.style.display="none"
}
return true;
}
</script>

<input type="button" onclick="return toggleMe('para1')" value="Toggle"><br>
<p id="para1">
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
</p>
<br>
<input type="button" onclick="return toggleMe('para2')" value="Toggle"><br>
<div id="para2">
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah

</div>
<br>
<input type="button" onclick="return toggleMe('para3')" value="Toggle"><br>
<span id="para3">
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah

</span>
Answer:1

if you add the following styles to your page, the paragraphs will be hidden by default.

<style>
    #para1, #para2{
        display:none;
    }
</style>
Answer:2

make a class for each element you want hidden by defaut, i.e

<p class="hidden">some hidden text</p>
<p class="hidden">more hidden text</p>

<style>
    .hidden
    {
        display:none;
    }
</style>
Answer:3

I have a piece of code, which communicate with iOS native layer by dispatching request with callback ID, and storing Deferred in array. Then when the callback comes, we can resolve or reject this ...

I have a piece of code, which communicate with iOS native layer by dispatching request with callback ID, and storing Deferred in array. Then when the callback comes, we can resolve or reject this ...

I'm currently using enyo and I have a function on a component that takes a callback function and makes an ajax call, then calls the callback on success. I can't seem to figure out how to spy on the ...

I'm currently using enyo and I have a function on a component that takes a callback function and makes an ajax call, then calls the callback on success. I can't seem to figure out how to spy on the ...

  1. ajax callback
  2. ajax callback function
  3. ajax datatable callback
  4. call ajax callback
  5. ajax callback error
  6. callback after ajax
  7. callback function ajax not working
  8. jquery ajax callback
  9. html callback ajax
  10. get callback ajax jquery
  11. using callback ajax
  12. call callback function ajax
  13. call back method in ajax
  14. ajax callback in oracle apex
  15. ajax call back button
  16. ajax callback example
  17. callback function in jquery ajax
  18. ajax callback drupal 8
  19. ajax callback drupal 7
  20. ajax callback data

I tried many solutions I found on the web. None worked. I'm trying to make a website scroll horizontally when I'm scrolling vertically. I tried to accomplish this via js - nothing. Then I read that I ...

I tried many solutions I found on the web. None worked. I'm trying to make a website scroll horizontally when I'm scrolling vertically. I tried to accomplish this via js - nothing. Then I read that I ...

I'm writing a node wrapper to interact with an external api and am having a difficult time testing the asynchronous createJob method. Below is the test case code: api_key = "...

I'm writing a node wrapper to interact with an external api and am having a difficult time testing the asynchronous createJob method. Below is the test case code: api_key = "...

  1. mocha test asynchronous function
  2. mocha tests async
  3. mocha test asynchronous callback
  4. mocha test asynchronous code
  5. mocha test asynchronous calls
  6. mocha asynchronous tests
  7. mocha test async function
  8. mocha test async await
  9. mocha test async error
  10. mocha test async method
  11. mocha test async code
  12. mocha test async done
  13. mocha test async promise
  14. mocha test async await function
  15. mocha async tests timeout
  16. mocha async test example
  17. mocha async test order
  18. mocha async test fail
  19. mocha async test case
  20. mocha dynamic tests async