zoukankan      html  css  js  c++  java
  • jquery 提示语淡入效果

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title> jquery 提示语淡入</title>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
    <link rel="stylesheet" type="text/css" href="" />
    <style type="text/css">
    .tishi-com{display:none;width:65px;height:20px;line-height:20px; background:#fff9c9; border:1px solid #c7bf93; color:#666;
    position:relative;left:230px;top:-22px;}
    </style>
    <script type="text/javascript" src="jquery-3.0.0.js"></script>
    </head>
    
    <body>
        <div style="500px;height:200px;border:1px solid #E5E5E5;margin:0 auto;">
            <div style="height:50px;100%;">
                <label class="user-label">用户名:</label>
                <input  type="text" class="username" name="username"/>
                <div class="tishi-com">
                    <span class="tishi-font font-12"></span>
                </div>
            </div>
    
        <div style="height:50px;100%;">
            <label class="user-label">手机号:</label>
            <input  type="text" class="phone" name="phone"/>
            <div class="tishi-com">
                <span class="tishi-font font-12"></span>
            </div> 
        </div>
    
            <div>
            <input type="submit" class="fade" value="提交" />
            </div>
        </div>
    
    <script type="text/javascript">
        $(document).ready(function(){
            $(".fade").click(function(){
                var name=$.trim($(".username").val());
                var phone=$.trim($(".phone").val());
                if(name==""){
                    $('input[name=username]').siblings('.tishi-com').fadeIn();
                    $('input[name=username]').siblings('.tishi-com').find('.tishi-font').text('不能为空');
                }
                if(phone==""){
                    $('input[name=phone]').siblings('.tishi-com').fadeIn();
                    $('input[name=phone]').siblings('.tishi-com').find('.tishi-font').text('不能为空');
                }
            });
        });
    
    </script>
    </body>
    </html>

  • 相关阅读:
    MVC filter
    常见的页面中两个div自适应等高CSS控制
    字符串排序 获取字符串中最长的单词
    js中“==”与“===”区别
    数组中字符串按照长度大小排序
    jquery中ajax使用
    关于ajax
    父级div宽度100%,子级一个div宽度固定,另一个宽度自适应
    window.onload与$(document).ready()区别
    盒模型
  • 原文地址:https://www.cnblogs.com/yangzailu/p/6756022.html
Copyright © 2011-2022 走看看