简体   繁体   中英

How to simulate click on dropdown list?

Here is Google registration page . There is a dropdown list. How to simulate click on it using jQuery? My code doesn't work.

$('#Gender').click()

在此处输入图片说明

PS I am wiritng userscript for another google website and there are same dropdowns. So I don't want to make a script for autoregistration, don't worry.

尝试$('#Gender').trigger("click");

You can do it with HTML + javascript, but it works only on Chrome.

Check this Stack Overflow answer .

By looking your screenshot it appear that it is not a real dropdown (ie select tag) .

I believe your are using kendodropdown or jquery UI combobox or etc .

it change the dropdown to span,textbox combination and also change the id. To fire click event first inspect the element ,then bind it using the actual generated id or you can use class to bind the event .

if this doesn't help you provide html and javascript .

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