Jayanand Raghuwanshi
Jayanand Raghuwanshi

Reputation: 499

How to write Jasmine spec for jQuery click event with handler

Below is a code sample for the method for which I am struggling to write a spec. How do I call below event from example-spec.js?

$('.send-me').on('click', 'a.cloth-tile.active', function(event) {
  // write code here
}

Currently I am writing $(.send-me).click() but it is not working

Upvotes: 0

Views: 24

Answers (1)

Rory McCrossan
Rory McCrossan

Reputation: 337656

The event is bound to a.cloth-tile.active, so that's where you need to raise the event. You also need to wrap the selector string in quotes:

$('a.cloth-tile.active').click()

Note that this will raise the event on all of those elements in the DOM. If you want to target a specific one use its index.

Upvotes: 1

Related Questions