Html Show/hide a DIV on click <a>

Solved
Pascal_22 Posted messages 559 Status Member -  
 jepstif -
Bonjour,

I would like to know if it is possible, with the help of CSS, to display and hide a DIV when clicking on a link <a href>?

How can we detect from CSS that a link has been clicked?

Thank you very much

Pascal_22

Configuration: Windows 7 / Internet Explorer 8.0

7 answers

  1. MastercroW Posted messages 1259 Registration date   Status Member Last intervention   163
     
    Good evening,
    Here's a very simple solution in js:

    Between <head> and </head>
    <script type="text/javascript"> function switchInfoPerso() { divInfo = document.getElementById('divacacher'); if (divInfo.style.display == 'none') divInfo.style.display = 'block'; else divInfo.style.display = 'none'; } </script>


    HTML Code
    <a href="javascript: switchInfoPerso();">Show the text</a>
    <div id="divacacher" style="display: none;">The text that is hidden</div>

    --
    ░░░░▒▒▒▒████ ♠ MastercroW ♠ ████▒▒▒▒░░░░
    24
    1. patata
       
      With this solution, we can display only one div, but not multiple. It's buggy! :/
      0
      1. imane > patata
         
        You can try using class instead of id in the div tag.
        0
    2. jepstif
       
      Hello
      thank you for this post that answered my question
      how to hide a div?
      thank you very much
      happy holidays
      0