"html代码"

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <script src="http://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js"></script>
    <style type="text/css">
        *{
            padding: 0;
            margin: 0;
        }
        .box{
            margin: 200px auto;
            width: 200px;
            height: 200px;
            overflow: hidden;
            display: block;
        }
    </style>
</head>
<body>
    <div class="box">
        1.<input type="checkbox">
        2.<input type="checkbox">
        3.<input type="checkbox">
        4.<input type="checkbox">
        <input type="button" value="按钮" id="btn">
    </div>
</body>
</html>

"Jquery代码"

<script type="text/javascript">
        $(function(){
            $('#btn').click(function() {
                //选择所有的checkbox
                $('.box').find('input:checkbox').each(function() {
                    //方法一,原生对象
                    if ($(this)[0].checked) {
                        alert(1)
                    };
                    //方法二
                    if ($(this).is(':checked')) {
                        alert(1)
                    };
                });
            });
        })
    </script>

jquery validate自定义验证规则

jQuery.validator.addMethod("check_user", function(value, element) { var check = /^[A-Za-z\s]+$/; //this.optional(element)如果元素...

阅读全文

jquery-fancybox JavaScript图片库,支持pc,响应式

官网地址 http://fancyapps.com/fancybox/3/ document:http://fancyapps.com/fancybox/3/docs/#usage github https://github.com/fancyapps/fancybox 兼容性 ...

阅读全文

jquery 瀑布流插件 masonry

github https://github.com/desandro/masonry Masonry Cascading grid layout library Masonry works by placing elements in optimal position based on a...

阅读全文

欢迎留言