求解: jQuery在文本框中输入的信息如果是错误的时候,则出现后面红色的文字,知道的朋友请回复一下,谢谢

如题所述

<input id="username" ><span style="color:red;display:hidden">用户名由..</span>
<br/>
<input id="password"><span style="color:red;display:hidden">密码由...</span>

<script>
    $(function(){
        $("#username").blur(function(){
                var username = $(this).val();//用户名
                if(用户名错误){
                    $(this).next().show();
                }else{
                    $(this).next().hide();
                }
        });
        
    $("#password").blur(function(){
                    var pwd= $(this).val();//密码
                    if(密码错误){
                        $(this).next().show();
                    }else{
                        $(this).next().hide();
                    }
            });
        });
</scrpit>

温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答