Skip to main content

HTML/JavaScript Accordion on Blogger

 

HTML

1
2
3
4
<button class="acc">Show Answer</button>
<div class="pnl">
  <p></p>
</div>

CSS

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
.acc {
  background-color: #eee;
  color: #444;
  cursor: pointer;
  padding: 18px;
  width: 100%;
  border: none;
  text-align: left;
  outline: none;
  font-size: 15px;
  transition: 0.4s;
}
.active, .acc:hover {
  background-color: #ccc;
}
.pnl {
  padding: 0 18px;
  display: none;
  background-color: white;
  overflow: hidden;
}

JavaScript

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<script type='text/javascript'>
     
//<![CDATA[
     var acc = document.getElementsByClassName("acc");
     var i;
    for (i = 0; i < acc.length; i++) {
  acc[i].addEventListener("click", function() {
    this.classList.toggle("active");
    var pnl = this.nextElementSibling;
    if (pnl.style.display === "block") {
      pnl.style.display = "none";
    } else {
      pnl.style.display = "block";
    }
  });
}
    //]]>
 
</script>

Comments

Popular posts from this blog

C Program to Swap Two Numbers

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 #include<stdio.h> int main() {        double first, second, temp;        printf ( "Enter first number: " );        scanf ( "%lf" , &first);        printf ( "Enter second number: " );        scanf ( "%lf" , &second);          temp = first;          first = second;          second = temp;          printf ( "\nAfter swapping, firstNumber = %.2lf\n" , first);        printf ( "After swapping, secondNumber = %.2lf" , second);        return 0; } Output: 1 2 3 4 5 Enter first number: 2.50 Enter second number: 5.75   After swapping, firstNumber = 5.75 After swapping, secondNumber...

Crazy About Her | Netflix Official Site

Netflix Netflix UNLIMITED TV SHOWS & MOVIES JOIN NOW Sign Out Crazy About Her 2021 | 18+ | 1h 42m | Romantic Comedies After spending a wild night together, Adri discovers the only way to see Carla again is to become a patient at the psychiatric center where she resides. Starring: Álvaro Cervantes,Susana Abaitua,Luis Zahera Watch all you want. JOIN NOW Videos Crazy About Her Trailer: Crazy About Her More Details Watch offline Available to download Genres Spanish , Comedies , Dark Comedies , Romantic Movies , Romantic Comedies This movie is... Cynical , Offbeat , Intimate , Inspiring , Romantic Audio English , English , European Spanish - Audio Description , European Spanish [Original] , European Spanish - Audio Description , European Spanish [Original] Subtitles English , English , European Spanish Cast Álvaro Cervantes Susana Abaitua Luis Zahera Clara Segura Aixa Villagrán Paula Malia Nil Cardoner Txell Aixendri Alberto San Juan More Originals Coming Soon Murder by the Coast...

C Program to Add Two Integers

2 3 4 5 6 7 8 9 10 11 12 13 #include <stdio.h> int main() {           int num1, num2, sum;             printf ( "Enter two integers: " );      scanf ( "%d %d" , &number1, &number2);        sum = num + num2;                  printf ( "%d + %d = %d" , num, num, sum);      return 0; } Output: 1 2 3 Enter two integers: 61 39 61 + 39 = 100