Button not clickable through javascript The Next CEO of Stack OverflowHow do JavaScript closures work?What is the most efficient way to deep clone an object in JavaScript?How do I remove a property from a JavaScript object?Which equals operator (== vs ===) should be used in JavaScript comparisons?How do I include a JavaScript file in another JavaScript file?What does “use strict” do in JavaScript, and what is the reasoning behind it?How to check whether a string contains a substring in JavaScript?Loop through an array in JavaScriptHow do I remove a particular element from an array in JavaScript?For-each over an array in JavaScript?
Is HostGator storing my password in plaintext?
MAZDA 3 2006 (UK) - poor acceleration then takes off at 3250 revs
What happens if you roll doubles 3 times then land on "Go to jail?"
How to make a software documentation "officially" citable?
Apart from "berlinern", do any other German dialects have a corresponding verb?
Anatomically Correct Mesopelagic Aves
Was a professor correct to chastise me for writing "Prof. X" rather than "Professor X"?
When airplanes disconnect from a tanker during air to air refueling, why do they bank so sharply to the right?
How to start emacs in "nothing" mode (`fundamental-mode`)
When Does an Atlas Uniquely Define a Manifold?
How do I solve this limit?
How can I open an app using Terminal?
What do "high sea" and "carry" mean in this sentence?
Trouble understanding the speech of overseas colleagues
Why do professional authors make "consistency" mistakes? And how to avoid them?
How to count occurrences of text in a file?
Failed to fetch jessie backports repository
% symbol leads to superlong (forever?) compilations
Why does standard notation not preserve intervals (visually)
Science fiction (dystopian) short story set after WWIII
How do I get the green key off the shelf in the Dobby level of Lego Harry Potter 2?
Whats the best way to handle refactoring a big file?
How do we know the LHC results are robust?
Is a stroke of luck acceptable after a series of unfavorable events?
Button not clickable through javascript
The Next CEO of Stack OverflowHow do JavaScript closures work?What is the most efficient way to deep clone an object in JavaScript?How do I remove a property from a JavaScript object?Which equals operator (== vs ===) should be used in JavaScript comparisons?How do I include a JavaScript file in another JavaScript file?What does “use strict” do in JavaScript, and what is the reasoning behind it?How to check whether a string contains a substring in JavaScript?Loop through an array in JavaScriptHow do I remove a particular element from an array in JavaScript?For-each over an array in JavaScript?
I want to click a button (see attached) with javascript, in chrome console, but it doesn't work. I tried with ID and Class but no chance. If I want to click on an a element on the same site it's working fine with both lines..
What I tried:
document.getElementById('account-settings-save-button').click()
document.getElementsByClassName('btn-progress btn btn-primary icon-btn icon-right IDLE null')[0].click()
javascript google-chrome
add a comment |
I want to click a button (see attached) with javascript, in chrome console, but it doesn't work. I tried with ID and Class but no chance. If I want to click on an a element on the same site it's working fine with both lines..
What I tried:
document.getElementById('account-settings-save-button').click()
document.getElementsByClassName('btn-progress btn btn-primary icon-btn icon-right IDLE null')[0].click()
javascript google-chrome
Can you create a snippet reproducing the issue?
– Nisarg
Mar 8 at 12:41
2
How do you know it is not getting clicked?
– ndvo
Mar 8 at 12:44
I am watching the website and nothing happens when I click the button through the console. I am not sure how I could produce a snippet due to it is a webpage in a member area.
– Tim
Mar 8 at 12:49
add a comment |
I want to click a button (see attached) with javascript, in chrome console, but it doesn't work. I tried with ID and Class but no chance. If I want to click on an a element on the same site it's working fine with both lines..
What I tried:
document.getElementById('account-settings-save-button').click()
document.getElementsByClassName('btn-progress btn btn-primary icon-btn icon-right IDLE null')[0].click()
javascript google-chrome
I want to click a button (see attached) with javascript, in chrome console, but it doesn't work. I tried with ID and Class but no chance. If I want to click on an a element on the same site it's working fine with both lines..
What I tried:
document.getElementById('account-settings-save-button').click()
document.getElementsByClassName('btn-progress btn btn-primary icon-btn icon-right IDLE null')[0].click()
javascript google-chrome
javascript google-chrome
edited Mar 8 at 12:53
Tim
asked Mar 8 at 12:39
TimTim
186
186
Can you create a snippet reproducing the issue?
– Nisarg
Mar 8 at 12:41
2
How do you know it is not getting clicked?
– ndvo
Mar 8 at 12:44
I am watching the website and nothing happens when I click the button through the console. I am not sure how I could produce a snippet due to it is a webpage in a member area.
– Tim
Mar 8 at 12:49
add a comment |
Can you create a snippet reproducing the issue?
– Nisarg
Mar 8 at 12:41
2
How do you know it is not getting clicked?
– ndvo
Mar 8 at 12:44
I am watching the website and nothing happens when I click the button through the console. I am not sure how I could produce a snippet due to it is a webpage in a member area.
– Tim
Mar 8 at 12:49
Can you create a snippet reproducing the issue?
– Nisarg
Mar 8 at 12:41
Can you create a snippet reproducing the issue?
– Nisarg
Mar 8 at 12:41
2
2
How do you know it is not getting clicked?
– ndvo
Mar 8 at 12:44
How do you know it is not getting clicked?
– ndvo
Mar 8 at 12:44
I am watching the website and nothing happens when I click the button through the console. I am not sure how I could produce a snippet due to it is a webpage in a member area.
– Tim
Mar 8 at 12:49
I am watching the website and nothing happens when I click the button through the console. I am not sure how I could produce a snippet due to it is a webpage in a member area.
– Tim
Mar 8 at 12:49
add a comment |
3 Answers
3
active
oldest
votes
What do you want to do when this button clicked. You must say onclick="your_code_here"
Working example fiddle: here
<button
id="account-settings-save-button"
onclick="alert('click event occured')">
BUTTON
</button>
I don't create the html. I want to write a script which clicks this button a website.
– Tim
Mar 8 at 13:16
The functionality is that the website navigates to the next website
– Tim
Mar 8 at 13:17
In this case there can be a different problem. First are you sure that you are getting the right element withgetElemenetById
– Erdal SATIK
Mar 8 at 13:24
To find out you can console.log thisconsole.log('button', document.getElementById('account-settings-save-button'))
– Erdal SATIK
Mar 8 at 13:25
Yes it returns the right element
– Tim
Mar 8 at 13:29
add a comment |
Sometimes click won't work for example if you use it on <a>
tags it won't trigger link. You can try using MouseEvent API to simulate click event.
Here you can find nice example How to simulate a click event with vanilla JavaScript
In short, what you can try doing is:
//From the example above
var simulateClick = function (elem)
// Create our event (with options)
var evt = new MouseEvent('click',
bubbles: true,
cancelable: true,
view: window
);
// If cancelled, don't dispatch our event
var canceled = !elem.dispatchEvent(evt);
;
var buttonToClick = document.getElementById('account-settings-save-button');
simulateClick(buttonToClick);
I get an error document.getElemenyById is not a functin
– Tim
Mar 8 at 13:12
My bad misspelled the word, updated now. @Tim
– SergejV
Mar 8 at 13:13
Oh, I didnt saw either XD Now I don't get an error, but the button isn't clicked. Basically like before.
– Tim
Mar 8 at 13:22
Can you find in the source code of the page where they are catching this button click and post that? @Tim
– SergejV
Mar 8 at 13:26
How can I do that? Sorry I am a total beginner... :/
– Tim
Mar 8 at 13:30
|
show 3 more comments
I solved it. This website is using vue. So the command is:
document.getElementById('account-settings-save-button').__vue__.onClick();
Sorry this question wasn't able to be answered by you.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55063432%2fbutton-not-clickable-through-javascript%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
What do you want to do when this button clicked. You must say onclick="your_code_here"
Working example fiddle: here
<button
id="account-settings-save-button"
onclick="alert('click event occured')">
BUTTON
</button>
I don't create the html. I want to write a script which clicks this button a website.
– Tim
Mar 8 at 13:16
The functionality is that the website navigates to the next website
– Tim
Mar 8 at 13:17
In this case there can be a different problem. First are you sure that you are getting the right element withgetElemenetById
– Erdal SATIK
Mar 8 at 13:24
To find out you can console.log thisconsole.log('button', document.getElementById('account-settings-save-button'))
– Erdal SATIK
Mar 8 at 13:25
Yes it returns the right element
– Tim
Mar 8 at 13:29
add a comment |
What do you want to do when this button clicked. You must say onclick="your_code_here"
Working example fiddle: here
<button
id="account-settings-save-button"
onclick="alert('click event occured')">
BUTTON
</button>
I don't create the html. I want to write a script which clicks this button a website.
– Tim
Mar 8 at 13:16
The functionality is that the website navigates to the next website
– Tim
Mar 8 at 13:17
In this case there can be a different problem. First are you sure that you are getting the right element withgetElemenetById
– Erdal SATIK
Mar 8 at 13:24
To find out you can console.log thisconsole.log('button', document.getElementById('account-settings-save-button'))
– Erdal SATIK
Mar 8 at 13:25
Yes it returns the right element
– Tim
Mar 8 at 13:29
add a comment |
What do you want to do when this button clicked. You must say onclick="your_code_here"
Working example fiddle: here
<button
id="account-settings-save-button"
onclick="alert('click event occured')">
BUTTON
</button>
What do you want to do when this button clicked. You must say onclick="your_code_here"
Working example fiddle: here
<button
id="account-settings-save-button"
onclick="alert('click event occured')">
BUTTON
</button>
answered Mar 8 at 13:03
Erdal SATIKErdal SATIK
303418
303418
I don't create the html. I want to write a script which clicks this button a website.
– Tim
Mar 8 at 13:16
The functionality is that the website navigates to the next website
– Tim
Mar 8 at 13:17
In this case there can be a different problem. First are you sure that you are getting the right element withgetElemenetById
– Erdal SATIK
Mar 8 at 13:24
To find out you can console.log thisconsole.log('button', document.getElementById('account-settings-save-button'))
– Erdal SATIK
Mar 8 at 13:25
Yes it returns the right element
– Tim
Mar 8 at 13:29
add a comment |
I don't create the html. I want to write a script which clicks this button a website.
– Tim
Mar 8 at 13:16
The functionality is that the website navigates to the next website
– Tim
Mar 8 at 13:17
In this case there can be a different problem. First are you sure that you are getting the right element withgetElemenetById
– Erdal SATIK
Mar 8 at 13:24
To find out you can console.log thisconsole.log('button', document.getElementById('account-settings-save-button'))
– Erdal SATIK
Mar 8 at 13:25
Yes it returns the right element
– Tim
Mar 8 at 13:29
I don't create the html. I want to write a script which clicks this button a website.
– Tim
Mar 8 at 13:16
I don't create the html. I want to write a script which clicks this button a website.
– Tim
Mar 8 at 13:16
The functionality is that the website navigates to the next website
– Tim
Mar 8 at 13:17
The functionality is that the website navigates to the next website
– Tim
Mar 8 at 13:17
In this case there can be a different problem. First are you sure that you are getting the right element with
getElemenetById
– Erdal SATIK
Mar 8 at 13:24
In this case there can be a different problem. First are you sure that you are getting the right element with
getElemenetById
– Erdal SATIK
Mar 8 at 13:24
To find out you can console.log this
console.log('button', document.getElementById('account-settings-save-button'))
– Erdal SATIK
Mar 8 at 13:25
To find out you can console.log this
console.log('button', document.getElementById('account-settings-save-button'))
– Erdal SATIK
Mar 8 at 13:25
Yes it returns the right element
– Tim
Mar 8 at 13:29
Yes it returns the right element
– Tim
Mar 8 at 13:29
add a comment |
Sometimes click won't work for example if you use it on <a>
tags it won't trigger link. You can try using MouseEvent API to simulate click event.
Here you can find nice example How to simulate a click event with vanilla JavaScript
In short, what you can try doing is:
//From the example above
var simulateClick = function (elem)
// Create our event (with options)
var evt = new MouseEvent('click',
bubbles: true,
cancelable: true,
view: window
);
// If cancelled, don't dispatch our event
var canceled = !elem.dispatchEvent(evt);
;
var buttonToClick = document.getElementById('account-settings-save-button');
simulateClick(buttonToClick);
I get an error document.getElemenyById is not a functin
– Tim
Mar 8 at 13:12
My bad misspelled the word, updated now. @Tim
– SergejV
Mar 8 at 13:13
Oh, I didnt saw either XD Now I don't get an error, but the button isn't clicked. Basically like before.
– Tim
Mar 8 at 13:22
Can you find in the source code of the page where they are catching this button click and post that? @Tim
– SergejV
Mar 8 at 13:26
How can I do that? Sorry I am a total beginner... :/
– Tim
Mar 8 at 13:30
|
show 3 more comments
Sometimes click won't work for example if you use it on <a>
tags it won't trigger link. You can try using MouseEvent API to simulate click event.
Here you can find nice example How to simulate a click event with vanilla JavaScript
In short, what you can try doing is:
//From the example above
var simulateClick = function (elem)
// Create our event (with options)
var evt = new MouseEvent('click',
bubbles: true,
cancelable: true,
view: window
);
// If cancelled, don't dispatch our event
var canceled = !elem.dispatchEvent(evt);
;
var buttonToClick = document.getElementById('account-settings-save-button');
simulateClick(buttonToClick);
I get an error document.getElemenyById is not a functin
– Tim
Mar 8 at 13:12
My bad misspelled the word, updated now. @Tim
– SergejV
Mar 8 at 13:13
Oh, I didnt saw either XD Now I don't get an error, but the button isn't clicked. Basically like before.
– Tim
Mar 8 at 13:22
Can you find in the source code of the page where they are catching this button click and post that? @Tim
– SergejV
Mar 8 at 13:26
How can I do that? Sorry I am a total beginner... :/
– Tim
Mar 8 at 13:30
|
show 3 more comments
Sometimes click won't work for example if you use it on <a>
tags it won't trigger link. You can try using MouseEvent API to simulate click event.
Here you can find nice example How to simulate a click event with vanilla JavaScript
In short, what you can try doing is:
//From the example above
var simulateClick = function (elem)
// Create our event (with options)
var evt = new MouseEvent('click',
bubbles: true,
cancelable: true,
view: window
);
// If cancelled, don't dispatch our event
var canceled = !elem.dispatchEvent(evt);
;
var buttonToClick = document.getElementById('account-settings-save-button');
simulateClick(buttonToClick);
Sometimes click won't work for example if you use it on <a>
tags it won't trigger link. You can try using MouseEvent API to simulate click event.
Here you can find nice example How to simulate a click event with vanilla JavaScript
In short, what you can try doing is:
//From the example above
var simulateClick = function (elem)
// Create our event (with options)
var evt = new MouseEvent('click',
bubbles: true,
cancelable: true,
view: window
);
// If cancelled, don't dispatch our event
var canceled = !elem.dispatchEvent(evt);
;
var buttonToClick = document.getElementById('account-settings-save-button');
simulateClick(buttonToClick);
edited Mar 8 at 13:13
answered Mar 8 at 12:55
SergejVSergejV
2131514
2131514
I get an error document.getElemenyById is not a functin
– Tim
Mar 8 at 13:12
My bad misspelled the word, updated now. @Tim
– SergejV
Mar 8 at 13:13
Oh, I didnt saw either XD Now I don't get an error, but the button isn't clicked. Basically like before.
– Tim
Mar 8 at 13:22
Can you find in the source code of the page where they are catching this button click and post that? @Tim
– SergejV
Mar 8 at 13:26
How can I do that? Sorry I am a total beginner... :/
– Tim
Mar 8 at 13:30
|
show 3 more comments
I get an error document.getElemenyById is not a functin
– Tim
Mar 8 at 13:12
My bad misspelled the word, updated now. @Tim
– SergejV
Mar 8 at 13:13
Oh, I didnt saw either XD Now I don't get an error, but the button isn't clicked. Basically like before.
– Tim
Mar 8 at 13:22
Can you find in the source code of the page where they are catching this button click and post that? @Tim
– SergejV
Mar 8 at 13:26
How can I do that? Sorry I am a total beginner... :/
– Tim
Mar 8 at 13:30
I get an error document.getElemenyById is not a functin
– Tim
Mar 8 at 13:12
I get an error document.getElemenyById is not a functin
– Tim
Mar 8 at 13:12
My bad misspelled the word, updated now. @Tim
– SergejV
Mar 8 at 13:13
My bad misspelled the word, updated now. @Tim
– SergejV
Mar 8 at 13:13
Oh, I didnt saw either XD Now I don't get an error, but the button isn't clicked. Basically like before.
– Tim
Mar 8 at 13:22
Oh, I didnt saw either XD Now I don't get an error, but the button isn't clicked. Basically like before.
– Tim
Mar 8 at 13:22
Can you find in the source code of the page where they are catching this button click and post that? @Tim
– SergejV
Mar 8 at 13:26
Can you find in the source code of the page where they are catching this button click and post that? @Tim
– SergejV
Mar 8 at 13:26
How can I do that? Sorry I am a total beginner... :/
– Tim
Mar 8 at 13:30
How can I do that? Sorry I am a total beginner... :/
– Tim
Mar 8 at 13:30
|
show 3 more comments
I solved it. This website is using vue. So the command is:
document.getElementById('account-settings-save-button').__vue__.onClick();
Sorry this question wasn't able to be answered by you.
add a comment |
I solved it. This website is using vue. So the command is:
document.getElementById('account-settings-save-button').__vue__.onClick();
Sorry this question wasn't able to be answered by you.
add a comment |
I solved it. This website is using vue. So the command is:
document.getElementById('account-settings-save-button').__vue__.onClick();
Sorry this question wasn't able to be answered by you.
I solved it. This website is using vue. So the command is:
document.getElementById('account-settings-save-button').__vue__.onClick();
Sorry this question wasn't able to be answered by you.
answered Mar 9 at 11:14
TimTim
186
186
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55063432%2fbutton-not-clickable-through-javascript%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can you create a snippet reproducing the issue?
– Nisarg
Mar 8 at 12:41
2
How do you know it is not getting clicked?
– ndvo
Mar 8 at 12:44
I am watching the website and nothing happens when I click the button through the console. I am not sure how I could produce a snippet due to it is a webpage in a member area.
– Tim
Mar 8 at 12:49