Tom*_*Tom 31 html javascript css jquery
我有一个输入,它的类型设置为隐藏,我需要将其类型更改为文本.似乎无法弄清楚这一点,或者是否可以使用jQuery
Ian*_*non 58
使用jQuery 1.4,您可以在分离时更改输入的类型.
marker = $('<span />').insertBefore('#myInput');
$('#myInput').detach().attr('type', 'text').insertAfter(marker);
marker.remove();
Run Code Online (Sandbox Code Playgroud)
IE将不允许您出于安全原因更改表单元素的类型,因此我将使用Aram隐藏的div建议.
这是我将如何做到这一点:
$("input[type='hidden']").each(function(){
var name = $(this).attr('name'); // grab name of original
var value = $(this).attr('value'); // grab value of original
/* create new visible input */
var html = '<input type="text" name="'+name+'" value="'+value+'" />';
$(this).after(html).remove(); // add new, then remove original input
});
Run Code Online (Sandbox Code Playgroud)
如果你想过滤一些元素,在每个()之前调用filter(),如下所示:
$("input[type='hidden']").filter("[name='whatever']").each(function...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
62923 次 |
| 最近记录: |