我可以在jQuery中向textbox添加下拉列表,例如datepicker [英] Can I add a dropdownlist to textbox like datepicker in jQuery

查看:48
本文介绍了我可以在jQuery中向textbox添加下拉列表,例如datepicker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文本框,我想绑定下拉列表控件就像jquery中的datepicker一样。

这是否可行。

请建议..



我尝试这个,这是绑定在jquery的click事件上..

 function EditAge(){
var lblStudAge = $('#Age')。html();
var dropDownStudAge ='< 选择 id = ddlAge > ';
for(var count = 10; count < = 25; count ++) {

dropDownStudAge + =' < option value =' + count + 已选择 > '+ count +'< / option > ';
}
dropDownStudAge + ='< / select > ';
$('#Age')。html(dropDownStudAge);
$('#ddlAge')。val(lblStudAge.split('')[0]);

}

解决方案

('#Age')。html();
var dropDownStudAge ='< 选择 id = ddlAge > ';
for(var count = 10; count < = 25; count ++) {

dropDownStudAge + =' < option value =' + count + 已选择 > '+ count +'< / option > ';
}
dropDownStudAge + ='< / select > ';

(' #年龄 ')。HTML(dropDownStudAge);

(' # ddlAge')。val(lblStudAge.split('')[0]);

}


I have a textbox and I want to bound dropdownlist control on it like datepicker in jquery.
Is this possible or not.
Please suggest..

I try this one, that is bound on click event of jquery..

function EditAge() {
            var lblStudAge = $('#Age').html();
            var dropDownStudAge = '<select id="ddlAge">';
            for (var count = 10; count <= 25; count++) {

                dropDownStudAge += '<option value="' + count + '"selected>' + count + '</option>';
            }
            dropDownStudAge += '</select>';
            $('#Age').html(dropDownStudAge);
            $('#ddlAge').val(lblStudAge.split(' ')[0]);

        }

解决方案

('#Age').html(); var dropDownStudAge = '<select id="ddlAge">'; for (var count = 10; count <= 25; count++) { dropDownStudAge += '<option value="' + count + '"selected>' + count + '</option>'; } dropDownStudAge += '</select>';


('#Age').html(dropDownStudAge);


('#ddlAge').val(lblStudAge.split(' ')[0]); }


这篇关于我可以在jQuery中向textbox添加下拉列表,例如datepicker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆