jQuery:将元素类型从隐藏更改为输入 [英] jQuery: Change element type from hidden to input

查看:126
本文介绍了jQuery:将元素类型从隐藏更改为输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个输入,它的类型设置为隐藏,我需要将其类型更改为文本。使用jQuery 1.4你可以改变一个输入的类型(例如,你可以改变输入的类型)

  marker = $('< span />').insertBefore('#myInput'); 
$('#myInput')。detach()。attr('type','text')。insertAfter(marker);
marker.remove();


I've got an input which it's type is set to hidden, I need to change it's type to text. Can't seem to figure this out or if it's possible with jQuery

解决方案

With jQuery 1.4 you can change the type of an input while it's detached.

marker = $('<span />').insertBefore('#myInput');
$('#myInput').detach().attr('type', 'text').insertAfter(marker);
marker.remove();

这篇关于jQuery:将元素类型从隐藏更改为输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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