js触发select下拉

$(document).ready(function() {
    $('i').click(function() {
        open($(this).parents('label').prev('select'));
    });
});
function open(elem) {
    if (document.createEvent) {
        var e = document.createEvent("MouseEvents");
        e.initMouseEvent("mousedown", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
        elem[0].dispatchEvent(e);
    } else if (element.fireEvent) {
        elem[0].fireEvent("onmousedown");
    }
}

你可能感兴趣的:(js触发select下拉)