How to trigger two button by jquery

html, jquery

Solution

You can use `:lt()` selector

Select all elements at an index less than `index` within the matched set.

$('#btn-list button:lt(2)').trigger('click');

OR, You can use `:eq()`

$('#btn-list').find('button:eq(0), button:eq(1)').trigger('click');

Problem

here is my html code ``` <ul id="btn-list"> <li><span><button class="btn btn-warning btn-lg">Btn1</button></span></li> <li><span><button class="btn btn-warning btn-lg">Btn2</button></span></li> <li><span><button class="btn btn-info btn-lg">Btn3</button></span></li> </ul> ``` I want to trigger `click` event of `btn1` and `btn2`, but I don't have any idea how to write the specific button selector where no name and id attribute not assigned to the respective buttons ``` $("#btn-list ???").trigger("click"); ```

Original source