简体   繁体   中英

click() function does not on any browser console

When I open a website on the browser. Now I want to click button through javascript console which every browser has. The button have class and the website is not using jquery so the code will be pure javascript.

document.getElementsByClassName('btn-orange').trigger('click'); document.getElementsByClassName('btn-orange').click();

Thank you for taking time for helping me.

document.getElementsByClassName('btn-orange')[0].click();

这将起作用,因为document.getElementsByClassName('btn-orange')将为您提供一组选定的DOM元素,即使您只有一个具有此类名称的元素,它也会位于该数组的第一个位置,然后调用该元素上的点击事件。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM