JavaScript click a button by name from chrome console

后端 未结 4 545
刺人心
刺人心 2021-01-01 04:30

I\'m trying to click programmatically a button from a web page using chrome console.

(UPDATED)The code of the button looks like this :

<         


        
4条回答
  •  Happy的楠姐
    2021-01-01 04:47

    regarding the following HTML:

    
    

    you should be aware of:

    1. the character > should be entity encoded >
    2. when an attribute doesn't use quotes (" or ') to delimit its value, all characters until the first space or > are interpreted as the value. In your case this means that name=BTN_CHOICE5/> translates to name="BTN_CJOICE5/">.

    If the exercise of clicking the button is meant to submit the

    , you should know that synthetic events like .click() do not trigger default actions. May I suggest submitting the form instead?

    document.querySelector('form').submit()
    

提交回复
热议问题