Add and remove active class from nav-item (the simplest thin


Topic: Add and remove active class from nav-item (the simplest thing...)

nonayerbiz pro asked 5 years ago

Expected behavior

  $("li.nav-item").on('click', function(e){
console.log(e.target, new Date().toString());
$("li.nav-item.active").removeClass('active');
$(this).addClass('active');

})

click on the dropdown nav-item and it becomes "active"

Actual behavior

only works for nav-items without drop-down

Resources (screenshots, code snippets etc.)

*


Grzegorz Bujański staff commented 5 years ago

Hi. Please create snippet here: https://mdbootstrap.com/snippets/ i will look at this.


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Open

Specification of the issue
  • User: Pro
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: 4.16.0
  • Device: macbook
  • Browser: Firefox
  • OS: macOS
  • Provided sample code: No
  • Provided link: No