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?










1















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.enter image description here.



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()









share|improve this question
























  • 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
















1















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.enter image description here.



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()









share|improve this question
























  • 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














1












1








1








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.enter image description here.



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()









share|improve this question
















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.enter image description here.



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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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


















  • 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













3 Answers
3






active

oldest

votes


















0














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>





share|improve this answer























  • 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 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












  • Yes it returns the right element

    – Tim
    Mar 8 at 13:29


















0














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);





share|improve this answer

























  • 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



















0














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.






share|improve this answer























    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
    );



    );













    draft saved

    draft discarded


















    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









    0














    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>





    share|improve this answer























    • 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 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












    • Yes it returns the right element

      – Tim
      Mar 8 at 13:29















    0














    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>





    share|improve this answer























    • 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 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












    • Yes it returns the right element

      – Tim
      Mar 8 at 13:29













    0












    0








    0







    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>





    share|improve this answer













    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>






    share|improve this answer












    share|improve this answer



    share|improve this answer










    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 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












    • 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











    • 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












    • 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
















    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













    0














    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);





    share|improve this answer

























    • 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
















    0














    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);





    share|improve this answer

























    • 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














    0












    0








    0







    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);





    share|improve this answer















    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);






    share|improve this answer














    share|improve this answer



    share|improve this answer








    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


















    • 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












    0














    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.






    share|improve this answer



























      0














      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.






      share|improve this answer

























        0












        0








        0







        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.






        share|improve this answer













        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 9 at 11:14









        TimTim

        186




        186



























            draft saved

            draft discarded
















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

            2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

            Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme