jquery.FloatLabel.js jquery 浮动标签表单效果插件

jquery.FloatLabel.js jquery 浮动标签表单效果插件

第一步引入bfwone 加载jquery

第二步执行插件

示例如下

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>FloatLabel.js</title>
    <meta name="description" content="FloatLabel.js demo">
    <meta name="viewport" content="width=device-width">
    <link href="http://fonts.googleapis.com/css?family=Roboto:400,100,300,500,700,900" rel="stylesheet" type="text/css">
    <script id="bfwone" data="dep=jquery.17&err=0" type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/bfwone.js"></script>
    <script type="text/javascript">
        bready(function() {
            use(["jquery.FloatLabel", "normalize|jquery.FloatLabel|floatlabeljsdemo"], function() {
                // Init SmartPlaceholders.js

                $('.js-float-label-wrapper').FloatLabel();

                // ===============
                // Demo JavaScript
                // ===============

                // Show Modal on Submit

                $('#demoForm').on('submit', function(event) {

                    var modal = '<div class="modal"><h3>Your Product has been Saved</h3></div>',
                    blackout = '<div class="blackout"></div>';

                    $('.wrapper').prepend(blackout).hide().fadeIn().append(modal);
                    event.preventDefault();

                });

                // Destroy Modal when Clicked

                $('body').on('click', '.blackout, .modal', function() {
                    $('.blackout').fadeOut(function() {
                        $(".modal").fadeOut();
                    });
                });
            });
        });
    </script>

 
</head>
<body>

    <div class="wrapper">

        <h1>FloatLabel.js</h1>

        <form id="demoForm" action="#">

            <div class="js-float-label-wrapper">
                <label for="productName">产品名称</label>
                <input id="productName" type="text" />
            </div>

            <div class="js-float-label-wrapper">
                <label for="productPrice">价格</label>
                <input id="productPrice" type="text" />
            </div>

            <div class="js-float-label-wrapper">
                <label for="productDescription">描述</label>
                <textarea id="productDescription" rows="4"></textarea>
            </div>

            <input type="submit" value="保 存" />

        </form>

        <p class="attributes">
            <a href="https://github.com/m10l/FloatLabel.js">FloatLabel.js</a> by <a href="https://twitter.com/innernets" target="_blank">Mike Mitchell</a>
            <br />
            Based on <a href="http://dribbble.com/shots/1254439--GIF-Mobile-Form-Interaction?list=users" target="_blank">Matt Smith's concept</a>
        </p>

    </div>
</body>
</html>

官网 https://github.com/m10l/FloatLabel.js
立即下载jquery.FloatLabel.js查看所有js插件

网友评论0

程序员在线工具箱