Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

用JS展开select的下拉框 #11

Open
mishe opened this issue Nov 26, 2015 · 1 comment
Open

用JS展开select的下拉框 #11

mishe opened this issue Nov 26, 2015 · 1 comment

Comments

@mishe
Copy link
Owner

mishe commented Nov 26, 2015

function showallselect(id){
    var select = document.getElementById(id);
    if(select && select.options && select.options.length >1){
        select.size = select.options.length;
    }
}
···
@mishe
Copy link
Owner Author

mishe commented Dec 25, 2015

唤起select的option展开

zepto方式:

$(sltElement).trrgger("mousedown");
原生js方式:

function showDropdown(sltElement) {
var event;
event = document.createEvent('MouseEvents');
event.initMouseEvent('mousedown', true, true, window);
sltElement.dispatchEvent(event);
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant