0

there is a lot of similiar questions, but I have a problem that I want to trigger event which is already set. The code on the page is:

<a class="btn-medium btn-primary TradeCurrencyModalBtn">Start</a>

I used Visual Event plugin and it showed this: enter image description here

As you can see, the button has his own function set.
But my code does nothing:

$( document ).ready(function() {
    $("a.btn-medium btn-primary TradeCurrencyModalBtn").trigger("click");
});

When I click on trigger event (in the picture), it triggers perfectly. This is what I tried (none of them working):

$("a.btn-medium btn-primary TradeCurrencyModalBtn")[0].trigger("click");

$("a.btn-medium btn-primary TradeCurrencyModalBtn")[0].click();

$("a.btn-medium btn-primary TradeCurrencyModalBtn").click();

I even tried deleting all other elements, still not triggering from my code. Any ideas? I have implemented the latest JQuery.

1
  • it's possible jQuery is stopping event propagation through that click event handler. Can you try removing the already existing handler and just attach your own, as a test? this might be relevant. Commented Jul 12, 2014 at 18:53

1 Answer 1

3

your selector is wrong.

do like this:

$("a.btn-medium.btn-primary.TradeCurrencyModalBtn").trigger("click"); 
// tirgger click for anchor tag which has class btn-medium  btn-primary TradeCurrencyModalBtn

as you are trying to fire click for anchor which has all these classes.

Sign up to request clarification or add additional context in comments.

1 Comment

Oh how could I be so dumb... Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.