Jquery show/hide password

前端 未结 7 743
失恋的感觉
失恋的感觉 2021-02-10 17:33

Below Jquery is working fine but How could I shorten this Jquery? I have to show and hide the password for password and confirmed password? https://jsfiddle.net/c5cvLo54/1/

相关标签:
7条回答
  • 2021-02-10 18:34
    <script>
            
            $(document).ready(function(){
    
                $('#btn').click(function(){
    
                    var paswd= $('#password');
                    if(paswd.attr("type")== "password"){
    
                        paswd.attr("type","text");
    
                        $('#btn').attr("value","hide");
                        
                    }
                    else{
                            paswd.attr("type","password");
    
                            $('#btn').attr("value","show");
                    }
                })
            });
        
           
        </script>
    
    0 讨论(0)
提交回复
热议问题