replace input with javascript

前端 未结 3 1429
迷失自我
迷失自我 2021-01-25 05:40

Hello everybody I\'m trying to replace the \'text\' input type to \'password\' . And it works with following code :

function replaceT(obj){
            var newO=         


        
3条回答
  •  再見小時候
    2021-01-25 06:03

    This should work across all browsers:

    newO.className = obj.className;
    

    I'm not sure whether you should use className or class in setAttribute, but whatever it is, it is definitely the same as in getAttribute, so this is definitely wrong:

    newO.setAttribute('className' obj.getAttribute('class'));
    

提交回复
热议问题