JQuery使用trigger模拟触发selete的选择change事件

<!DOCTYPE HTML>
<html lang="en-US">
<head>
    <meta charset="UTF-8">
    <title>easonjim</title>
    <script src="scripts/jquery.js" type="text/javascript"></script>
</head>
<body>
<select id='province'>
    <option value='6'>66
    <option value='7'>77
    <option value='8'>88
</select>
<input type='button' id="btn1" value='setPi'>
<script type="text/javascript">
    $('#province').on("change", function () {
        alert($('#province').get(0).selectedIndex);
    });
    $('#btn1').on("click", function () {
        $('#province').get(0).selectedIndex = 1;
        $('#province').trigger("change");
    });
</script>
</body>
</html>

 

posted @ 2018-01-16 01:16  EasonJim  阅读(6578)  评论(0编辑  收藏  举报