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

            Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

            Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

            How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page