ASP.NET Core 5 MVC – drop down button not working

Issue

I have the code and markup shown here for a button, but for some reason the dropdown functionality does not work – need a fresh pair of eyes please…

<td class="text-right">
    <div class="btn-group">
        <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
        Action
        </button>
        <div class="dropdown-menu shadow animated--grow-in">
            <a class="dropdown-item">
                <i class="fas fa-pencil-alt"></i> Edit
            </a>
            <form class="d-inline">
                <a class="dropdown-item"><i class="fas fa-trash-alt"></i> Delete</a>
            </form>
        </div>
    </div>
</td>

Solution

Have you refered the css file and js file ?

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css" >
<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js" ></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/js/bootstrap.bundle.min.js" ></script>

Notice the css file should be refer before other css file and the order of js file could not be reversed

In my case:
enter image description here

Answered By – Ruikai Feng

Answer Checked By – Willingham (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.