Issue
I want to show the drop-down links in a particular order. Right now the order is -
- Link 1
- Link 3
- Link 2
HTML Code -
<ul class="navbar-nav">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown"></a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Link 1</a></li>
<li><a class="dropdown-item" href="#">Link 3</a></li>
</ul>
</li>
</ul>
Javascript Code -
if (role == "admin") {
$(".dropdown-menu").append('<li>'+
'<a class="dropdown-item" href="#">Link 2</a>'+
'</li>');
}
Can anyone tell me how can I show the links in the following order?
- Link 1
- Link 2
- Link 3
Solution
if (role == "admin") {
$(".dropdown-menu :first").after('<li>'+
'<a class="dropdown-item" href="#">Link 2</a>'+
'</li>');
}
Answered By - Vivekanand Vishvkarma Answer Checked By - David Marino (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.