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

298
Views
why Dropdown is not working after ajax call?

I am using jquery code to make drop down on sidebar filters. this code is working properly but after selecting a filter this code is not working , i think due to ajax call. what is solution. please guide me

jQuery(function(){
    jQuery("#sidebar h4, #sidebar h3, body.woocommerce #sidebar>div>.inner .widget h4, body.woocommerce #sidebar>div>.inner .widget h3").on('click', function(){
        jQuery(this).parent().toggleClass("dropdown-hide");
    });
});
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

jQuery(document).on('click', "SELECTOR", function(event){ 
});

This bind a click event to the document and all child elements within it. This method will works with dynamically created elements also

Working with jQuery(document).on( events

jQuery(function(){
        setTimeout(function () {
            jQuery('.btn-group').html('<button class="btn-default">Click</button>')
        },  1000);
        jQuery(document).on('click', ".btn-default", function(event){
            console.log('clicked');
        });
    });
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="btn-group"></div>

Not working with jQuery(selector).on( events

jQuery(function(){
        setTimeout(function () {
            jQuery('.btn-group').html('<button class="btn-default">Click</button>')
        },  1000);
        jQuery(".btn-default").on('click', function(){
            console.log('clicked');
        });
    });
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="btn-group"></div>

So, you have to change like below

jQuery(document).on('click', "#sidebar h4, #sidebar h3, body.woocommerce #sidebar>div>.inner .widget h4, body.woocommerce #sidebar>div>.inner .widget h3", function(event){

});
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!