I am trying to perform a trigger click of the button on the double click of the list element. I have 2 elements. One is a button and the second is a UL list element.
Here is the HTML button and List code.
<button type="button" class="btn btn-primary" data-toggle="modal" id="show_comment_modal" data-target="#showCommentModal"> Show Comment </button>
<ul>
<li id="category_list_1">Coffee</li>
<li id="category_list_2">Tea</li>
<li id="category_list_3">Milk</li>
</ul>
Here is the Jquery code:
$( "#category_list_1" ).dblclick(function() {
$( "#show_comment_modal" ).trigger( "click" );
});
I did not get any error in console. Did this even possible?
$('#show_comment_modal').click(function() {
alert('button click');
});
$('.category').dblclick(function() {
$('#show_comment_modal').click();
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button type="button" class="btn btn-primary" id="show_comment_modal"> Show Comment </button>
<ul>
<li class="category" id="category_list_1">Coffee</li>
<li class="category" id="category_list_2">Tea</li>
<li class="category" id="category_list_3">Milk</li>
</ul>
Here you have a code snippet with an example