JanusP
JanusP

Reputation: 17

Javascript click doesn't work

I'm simply trying to figure out how to automatically click the login button. Nothing I've tried works.

https://www.24option.com/24option/#Trade

I've tried:

$(".loginButton").click()
$("#loginButton").click()
$(".gwt-PushButton.loginButton.gwt-PushButton-up").click()

I've also tried using a few "click simulators" via javascript. Those didn't work either.

Any ideas how to just get the button to click via JS?

Upvotes: 1

Views: 1086

Answers (5)

Felipe Pereira
Felipe Pereira

Reputation: 12320

$("#TopPanel").find("#loginForm").submit();

but if you need only the click

$("#TopPanel").find("#loginForm").find('button').click();

After the las edit I think I'll give up, but if you want to keep trying I add this (in case real clicks are being detected somehow, play around with the coordinates or something)

var evt = document.createEvent("MouseEvents");
evt.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
document.getElementById("loginButton").parentNode.dispatchEvent(evt); 

Good luck

Upvotes: 1

26ph19
26ph19

Reputation: 393

Have you tried this?

$('.loginButton').on('click', function () {
    //code here
});

Upvotes: 1

Kanishka Panamaldeniya
Kanishka Panamaldeniya

Reputation: 17586

define the click function

$("#loginButton").click(function(){


  alert("clicked");

});

trigger the click function , inside document.ready function

$('#loginButton').trigger('click');

then the button wil be clicked automatically.

Upvotes: 0

user2712640
user2712640

Reputation: 31

Can you show more code? It works fine here:

var btn = document.getElementById("button");
btn.addEventListener("click", function(){ alert("button clicked"); });
btn.click();

Maybe you're having an error with DOM Selection. If you are, try using FireBug or the developer console in Chrome to catch it.

Upvotes: 0

use

$('.login_btn').click();

or

$('.login_btn').trigger('click');

Upvotes: 0

Related Questions