user4523851
user4523851

Reputation: 63

Click jQuery element targeted with css selector

I have the following code and I want to click on the Reset Button.

 <div class="col-md-3 filter-buttons">
     <button class="btn btn-primary"type="submit">Submit</button>
     <a class="btn btn-default" href="http://return.dev/ai?reset=1">Reset</a>
</div>

I tried with

$('.filter-buttons a.btn').click();

but doesn't work. Any ideas why?

Upvotes: 1

Views: 55

Answers (1)

Anoop Joshi P
Anoop Joshi P

Reputation: 25527

If you want to emulate the dom anchor element click, use,

$('.filter-buttons a.btn').get(0).click();

Otherwise it will trigger the jquery click event binded to that element. In this case you have not binded any click events to that anchor element.

Upvotes: 4

Related Questions