Home > Back-end >  Javascript click() is not working on a button
Javascript click() is not working on a button

Time:11-25

I have a button that has following HTML structure:

HTML Tree

When the button is inspected it points to last line: Edit Account

However, following line is not clicking the button (nor it is returning an error):

document.getElementById("AccountFile_Summary-AccountFile_SummaryScreen-EditAccount").children[0].children[1].click()

Any suggestions?

I tried followings, but did not work:

document.getElementById("AccountFile_Summary-AccountFile_SummaryScreen-EditAccount").click() document.getElementById("AccountFile_Summary-AccountFile_SummaryScreen-EditAccount").children[0].click()

CodePudding user response:

Could you use the following if the button is the only instance of the class 'gw-action--inner'?

document.querySelector('.gw-action--inner').click()

CodePudding user response:

Pretty much every element in webpage has "gw-action--inner" class tag. When I searched, it showed 119 matches.

  • Related