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

312
Views
UIkit Accordion: How to make links inside accordion-title clickable?
<div class="uk-accordion" data-uk-accordion>

    <div class="uk-accordion-title">
       <h3><a href="#">Title</a></h3>
       <div>something else</div>
    </div>
    <div class="uk-accordion-content">...</div>    
</div>

By default, once the accordion component is initiated, the whole element of .uk-accordion-title will become clickable and clicking it expands the content, even if users are clicking the link inside it. How can I make the links clickable and only clicking elsewhere expands the content?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Currently, UIKit's Accordion component needs the "uk-accordion-title" and "uk-accordion-content" elements to be grouped inside a 'parent', which is missing from your code. UIKit needs this parent in order to dynamically add a uk-open class to it, to make the accordion 'open'. So, your original code structure should be something like this:

<div uk-accordion>
  <div>
    <div class="uk-accordion-title">
       <h3><a href="https://example.com">Accordion Title</a></h3>
       <div>some accordion sub-title here</div>
    </div>
    <div class="uk-accordion-content">
      Accordion content that is displayed when open.
    </div>
  </div>  
</div>

The reason why your <a> element is not working as expected is because by default, when you click an <a> element, the click event will be allowed to 'propagate'. When the click happens inside a UIKit accordion title, UIKit will 'trap' that click event, and will override its default behaviour - using it to 'open' the accordion.

So, in order to stop UIKit from overriding the default <a> click behaviour, what you need to do is to get the <a> element to stop the click event from propagating to UIKit, like this:

<a href="https://example.com" onclick="event.stopPropagation();">

Now UIKit will not see the 'click', and won't override it - and the <a> element will be allowed to do its usual function when clicked.

Clicking somewhere else in the accordion title will still generate a 'click' event, which will be trapped by UIKit, and will open the accordion, as expected.

about 4 years ago · Juan Pablo Isaza Report
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!