您的位置:首页 > Web前端 > JavaScript

常用html控件的js用法

2017-01-04 15:27 316 查看
记录一些常用html控件的js用法

1、下拉框

下拉框设置text选中,类似 $("#select option[text='xxx']").attr("selected", true); 亲测为错误写法,并不能生效

function initSelector(ddl, text) {
$("#" + ddl + " option").each(function (i, item) {
if ($(item).text() == text) {
$(item).attr("selected", true);
}
});
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: