How to add bootstrap accordion with plus minus Toggle Icons?

here simple you can create index.html file and add Copy and paste this bootstrap accordion with plus minus source code: Toggle Bootstrap Accordion With Plus Minus Icons on Header Link Click Example with also Add minus icon for collapse element which is open by default as well as Toggle plus minus icon on show hide of collapse element.

bootstrap accordion with plus minus

Step 1: Include External Libs

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>

Step 2: Added HTML Code

<body>
<div class="bs-example">
    <div class="accordion" id="accordionExample">
        <div class="card">
            <div class="card-header" id="headingOne">
                <h2 class="mb-0">
                    <button type="button" class="btn btn-link" data-toggle="collapse" data-target="#collapseOne"><i class="fa fa-plus"></i> What is Pakainfo?</button>                                  
                </h2>
            </div>
            <div id="collapseOne" class="collapse" aria-labelledby="headingOne" data-parent="#accordionExample">
                <div class="card-body">
                    <p>tamilrockers new link 2019 free download today: If you excessively are reading this post it means that you excessively are watching for TamilRockers 2019-2020 latest URL. You are also probably worried about the same thing that the links which used to work for you earlier are not working anymore.<a href="https://www.pakainfo.com/tamilrockers-new-link-2019-free-download-300mb-movies/" target="_blank" rel="noopener noreferrer">Learn more.</a></p>
                </div>
            </div>
        </div>
        <div class="card">
            <div class="card-header" id="headingTwo">
                <h2 class="mb-0">
                    <button type="button" class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseTwo"><i class="fa fa-plus"></i> What is TamilRockers?</button>
                </h2>
            </div>
            <div id="collapseTwo" class="collapse show" aria-labelledby="headingTwo" data-parent="#accordionExample">
                <div class="card-body">
                    <p>So friends, there is no need to panic because in today’s article Tamil Rockers New Site URL Link 2019-2020 we are going to share with you all those Linux that are currently working for Tamilrockers HD movies free download. Yes friends, you are going to get the details of TamilRockers Current torrent website Domain link today. If you excessively are watching for this details then stay with us till the end.<a href="https://www.pakainfo.com/tamilrockers-new-link-2019-free-download-300mb-movies/" target="_blank" rel="noopener noreferrer">Learn more.</a></p>
                </div>
            </div>
        </div>
        <div class="card">
            <div class="card-header" id="headingThree">
                <h2 class="mb-0">
                    <button type="button" class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseThree"><i class="fa fa-plus"></i> What is Tamil?</button>                     
                </h2>
            </div>
            <div id="collapseThree" class="collapse" aria-labelledby="headingThree" data-parent="#accordionExample">
                <div class="card-body">
                    <p>This torrent website mainly uploads movies in Tamil as well as More languages ​​(Malayalam, Telugu, English, Hindi) on a daily basis. Not only this, you will get all the files uploaded in many file formats here. With which you have more option to Free download them.<a href="https://www.pakainfo.com/tamilrockers-new-link-2019-free-download-300mb-movies/" target="_blank" rel="noopener noreferrer">Learn more.</a></p>
                </div>
            </div>
        </div>
    </div>
</div>
</body>

Step 3: Add JS Code

<script>
    $(document).ready(function(){
        // Add minus icon for collapse element which is open by default
        $(".collapse.show").each(function(){
            $(this).prev(".card-header").find(".fa").addClass("fa-minus").removeClass("fa-plus");
        });
        
        // Toggle plus minus icon on show hide of collapse element
        $(".collapse").on('show.bs.collapse', function(){
            $(this).prev(".card-header").find(".fa").removeClass("fa-plus").addClass("fa-minus");
        }).on('hide.bs.collapse', function(){
            $(this).prev(".card-header").find(".fa").removeClass("fa-minus").addClass("fa-plus");
        });
    });
</script>

Step 4: Add CSS Code

<style>
    .bs-example{
        margin: 20px;
    }
    .accordion .fa{
        margin-right: 0.5rem;
    }
</style>

Full Source code for Bootstrap Accordion with plus minus

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Bootstrap 4 Accordion with Plus Minus Icons</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
<style>
    .bs-example{
        margin: 20px;
    }
    .accordion .fa{
        margin-right: 0.5rem;
    }
</style>
<script>
    $(document).ready(function(){
        // Add minus icon for collapse element which is open by default
        $(".collapse.show").each(function(){
            $(this).prev(".card-header").find(".fa").addClass("fa-minus").removeClass("fa-plus");
        });
        
        // Toggle plus minus icon on show hide of collapse element
        $(".collapse").on('show.bs.collapse', function(){
            $(this).prev(".card-header").find(".fa").removeClass("fa-plus").addClass("fa-minus");
        }).on('hide.bs.collapse', function(){
            $(this).prev(".card-header").find(".fa").removeClass("fa-minus").addClass("fa-plus");
        });
    });
</script>
</head>
<body>
<div class="bs-example">
    <div class="accordion" id="accordionExample">
        <div class="card">
            <div class="card-header" id="headingOne">
                <h2 class="mb-0">
                    <button type="button" class="btn btn-link" data-toggle="collapse" data-target="#collapseOne"><i class="fa fa-plus"></i> What is Bolly4u?</button>                                  
                </h2>
            </div>
            <div id="collapseOne" class="collapse" aria-labelledby="headingOne" data-parent="#accordionExample">
                <div class="card-body">
                    <p>This torrent website mainly uploads movies in Tamil as well as More languages ​​(Malayalam, Telugu, English, Hindi) on a daily basis. Not only this, you will get all the files uploaded in many file formats here. With which you have more option to Free download them.<a href="https://www.pakainfo.com/tamilrockers-new-link-2019-free-download-300mb-movies/" target="_blank" rel="noopener noreferrer">Learn more.</a></p>
                </div>
            </div>
        </div>
        <div class="card">
            <div class="card-header" id="headingTwo">
                <h2 class="mb-0">
                    <button type="button" class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseTwo"><i class="fa fa-plus"></i> What is TamilRokers?</button>
                </h2>
            </div>
            <div id="collapseTwo" class="collapse show" aria-labelledby="headingTwo" data-parent="#accordionExample">
                <div class="card-body">
                    <p>TamilRockers New Link: Want to know the way to get Tamilrockers New link ? or Tamilrockers Latest URL? it’s a simple trick 2019 by using a simple way. however before gathering Tamilrockers New link knowing little about Tamilrockers is Important. TamilRockers New Website 2020.<a href="https://www.pakainfo.com/tamilrockers-new-link-2019-free-download-300mb-movies/" target="_blank" rel="noopener noreferrer">Learn more.</a></p>
                </div>
            </div>
        </div>
        <div class="card">
            <div class="card-header" id="headingThree">
                <h2 class="mb-0">
                    <button type="button" class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseThree"><i class="fa fa-plus"></i> What is CSS?</button>                     
                </h2>
            </div>
            <div id="collapseThree" class="collapse" aria-labelledby="headingThree" data-parent="#accordionExample">
                <div class="card-body">
                    <p>If you too have a new Latest Tamil, Telugu, Malayalam Hindi Dubbed Movies Free Download Online, you keep searching for Tamilrockers New Website. Therefor today this post “Tamilrockers New link” will be very useful for you. Because Today I am Sharing List of Tamilrockers New link.<a href="https://www.pakainfo.com/tamilrockers-new-link-2019/" target="_blank" rel="noopener noreferrer">Learn more.</a></p>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about bootstrap accordion with plus minus.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.


Related FAQ

Here are some more FAQ related to this Article:

  1.   Simple Model Popup Box using HTML CSS and JavaScript
  2.   PHP Mail Attachment - Php Send Email File-Images Attachments
  3.   Laravel 5.6 PDF Generation using Dompdf Example
  4.   ASP.NET Page life cycle with Events
  5.   Class HTML not found laravel
  6.   Laravel MySQL Advanced Query Techniques with Example
  7.   jQuery Ajax Login Script using PHP MySQLi
  8.   Image Overlay Hover Effects With CSS3 Transitions
  9.   PHP Arrays Example Tutorial For Beginners From Scratch
  10.   How to upload image in codeigniter mysql database and display?
Tags:, , , , , , , ,