skip to Main Content

I want to trigger a double click on a button when the dropdown changes. Single click works for me but I want double click.

$('#fruitIds').change(function() {
  $("#btn-search").dblclick();
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<select name="fruits" id="fruitIds" style="width: 140px;">
  <option selected="selected" value="">Days</option>
  <option value="5">5 Days</option>
  <option value="10">10 Days</option>
  <option value="15">15 Days</option>
  <option value="20">20 Days</option>
  <option value="25">25 Days</option>
</select>

<button type="button" class="btn btn-primary btn1" id="btn-search">Apply Filter</button>

2

Answers


  1. According jQuery:s documentation dblClick is deprecated and should be replaced with trigger.

    Does this work for you:

    $('#fruitIds').change(function() {
      $("#btn-search").trigger( "dblclick" );
    });
    
    Login or Signup to reply.
  2. Check Your Jquery version jquery 3.6.4 version perfectly working.
    Example

    $("element").dblclick(function(){
         $(this).fadeOut();
      });
    
    
    $("element1").click(function(){
        $("element2").dblclick();
      });
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search