Topic: Make Dropdown main point clickable
BP-Webmedia pro asked 6 years ago
Hi, I want to make my Dropdown main point href linked on to a certain site.The idea is:-First klick, the dropdown menu opensSecond klick:- Href Link goes to another pageIs it possible?
Add comment
Mikołaj Smoleński staff answered 6 years ago
Hi,
I have prepared an example for You. I am not sure about Your issue, but take a look at the following code:
<!-- Basic dropdown --> <div class="btn-group"> <button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown" data-href="https://mdbootstrap.com/material-design-for-bootstrap/" aria-haspopup="true" aria-expanded="false">Basic dropdown</button> <div class="dropdown-menu"> <a class="dropdown-item" href="#">Action</a> <a class="dropdown-item" href="#">Another action</a> <a class="dropdown-item" href="#">Something else here</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="#">Separated link</a> </div> </div>
<script> $(document).ready(function () { let count = 0; $('.dropdown-toggle').on('click', function() { count++; let url = $(this).attr('data-href'); if(count % 2 == 0) { window.open(url,'_blank'); } }) }); </script>Best Regards
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Status
Resolved
Specification of the issue
- ForumUser: Pro
- Premium support: No
- Technology: MDB jQuery
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: No
- Provided link: No
Tags