如何将 html 页面上的下拉字段更改为输入 type=text。
我使用了 j 查询,但它不起作用,这是我的代码片段
$("[name=checkload1_c]").prop('type','text');
checkload1_c 是字段下拉列表的名称
最佳答案
我建议替换该元素而不是更改它,例如以下代码:
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
}
关于jquery - 更改字段类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32246051/