如何将html页面上的下拉字段更改为输入type=text。
我使用了j查询,但它不起作用,下面是我的代码片段
$("[name=checkload1_c]").prop('type','text');checkload1_c是下拉列表字段的名称
发布于 2015-08-27 17:58:45
您不能将下拉列表(<select>)更改为可编辑,如下所示。但是您可以使用一些JavaScript库来代替它。可编辑下拉菜单也称为Combobox。您可以尝试使用google的combobox库。以下是几个例子:
发布于 2015-08-27 18:00:36
我建议替换元素而不是更改它,就像下面这样的代码:
https://jsfiddle.net/s1pwkrpd/
$("button").click(function() {
replace("checkload1_c") //execute the replacement
})
function replace(name) {
$input = $("<input>", {type:"text", name:name}) //create a new element with same name
$("[name=" + name + "]").replaceWith($input) //replace the old element
}https://stackoverflow.com/questions/32246051
复制相似问题