Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

139
Views
Boostrap 5 collapse set show instead of toggle and allow anchor execution

Is there a way via the html attributes to have a link that will only "open" a collapsible target (if it's already open then just just stays open) and anchor link to it with the hashtag.

When I add "data-bs-toggle" my anchor href="#dashboard-VC" doesn't work. <a class="btn" href="#dashboard-VC" data-bs-toggle="collapse" data-bs-target="#dash-VC">{{NAME}}</a>

I can add this JS to move the screen but I wanted to avoid having to add this if there's a way to tell BS5 to allow the click event to bubble through without writing extra JS <a class="btn" href="#dashboard-VC" onclick="document.getElementById('dashboard-VC').scrollIntoView();" data-bs-toggle="collapse" data-bs-target="#dash-VC">{{NAME}}</a>

Now the next one is I want this to only "open" the collapsible area not toggle it. This button is a shortcut at the top of the page that will scrolldown to bring this area into view and "open" it if it's not already open. I can write JS to do everything but I was hoping to keep it all JS free and just use BS5 HTML attributes to handle it but not sure if that's possible.

I tried data-bs-toggle="open" but that's not a thing hoping it just wasn't documented. Maybe there's something other then the collapse competent that would handle this better?

Here is a working example but all in JS which is what I wanted to avoid having in the code: <a class="btn" href="#dashboard-VC" onclick="document.getElementById('dashboard-VC').scrollIntoView();document.getElementById('dash-VC').classList.add('show')">{{NAME}}</a>

Thanks.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!