Jquery实现对select的操作

  • select实现对文本框的显示和隐藏
    /**
    * 通过select的值实现对文本框的显示和隐藏
    * #id为一个select控件
    * .obj为一个文本框
    */
    function initSelector() {
            if ($('#id').val() != 1) {
                $('.obj').hide();
            }
            $('#id').change(function () {
                var id = $(this).children('option:selected').val();
                if (id== 1) {
                    $('.obj').show()
                } else {
                    $('.obj').hide()
                }
            });
        }

     

posted @ 2019-08-27 15:13  好胖的兔子  阅读(462)  评论(0编辑  收藏  举报