zoukankan      html  css  js  c++  java
  • jq的一点点

    $(document).ready(function(){
        // ???
        /*$(":button").click(function(){
            $(":text").each(function(){
                alert(this.value);
            });
        });*/
        // attr
        /*$("#all").click(function(){
            if($("#all").attr("checked")){
                $(":checkbox:not('#another')").attr("checked",false);
            } else {
                $(":checkbox:not('#another')").attr("checked",true);
            }
        });*/
        // ????????---prop
        $("#all").click(function(){
            var flag = $("#all").prop("checked");
            $(":checkbox:not(#all,#another)").prop("checked",flag);
        });
        /*
        $("#another").click(function(){
            var flag = $("#another").prop("checked");
            if($(":checkbox:not(#all,#another)").prop("checked",flag)){            
                this.prop("checked",!flag);
            } else {
                this.prop("checked",flag);
            }
        });
        */
        $("#another").click(function(){
            $(":checkbox:not(#all,#another)").each(function(i,v){
                $(this).prop("checked",!v.checked);
            })    
        });
        // 选中
        $("#s").bind("click",function(){
            alert($("#s option:selected").text());
        });
        
        // 单拉值
        $("input[name=danla]").bind("click",function(){
            $("#x option[name=danxuan][value=3]").attr("selected","selected");
            alert($("#x option:selected").text());
            $("div[class=div3]").append($('#x option:selected').text());
        });
        // 多拉值
        $("input[name=duola]").bind("click",function(){
            $("#d option[name=duoxuan][value=2]").attr("selected","selected");
            $("option[name=duoxuan][value=5]").attr("selected","selected");
            alert($("#d option:selected").text());
            $("div[class=div3]").append($("#d option:selected").text());
        });
        // 单选值
        $("input[name=danxuan2]").bind("click",function(){
            $("input[id=r2]").attr("checked","checked");
            alert($("input[type=radio][name=dan]:checked").val());
            $("div[class=div3]").append($("input[type=radio][name=dan]:checked").val());
        });
        // 多选值
        $("input[name=duoxuan2]").bind("click",function(){
            $("input[id=d2]").attr("checked","checked");
            $("input[id=d4]").attr("checked","checked");
            $("input[type=checkbox][name=duo]:checked").each(function(i){
                alert($(this).val());
                $("div[class=div3]").append($(this).val());
            });
        });
        //? 打印结果
        $("input[name=dayin]").bind("click",function(){
        //    $("div[class=div3]").slideToggle("slow");    // 滑动
            $("div[class=div3]").fadeToggle("slow");    // 淡出
            $("div[class=div3]").append($('#x option:selected').text());
            $("div[class=div3]").append($("#d option:selected").text());
            $("div[class=div3]").append($("input[type=radio][name=dan]:checked").val());
            $("input[type=checkbox][name=duo]:checked").each(function(i){
                alert($(this).val());
                $("div[class=div3]").append($(this).val());
            });
        });
        // 选中段落
        $("p[name=page]").bind("click",function(){
            alert($(this).text());
        });
        // 隔行变色
        $("#tb :nth-child(2n)").css("background","red");
        // 选中个数
        $("#num").bind("click",function(){
            alert($("input[name=aihao]:checked").size());
            $("input[name=aihao]:checked").each(function(){
                alert($(this).val());
            });
        });
        // 显示品牌
        $("#showall").bind("click",function(){
                $("li:nth-child(1n + 7)").not("#aa").slideToggle("slow");
                if($("#showall").val()=="显示精简品牌"){
                    $("#showall").val("显示全部品牌");
                } else {
                    $("#showall").val("显示精简品牌");
                }
                
        });
        // 焦点
        $("#text").focus();    // 文本框一开始就自动获取焦点
        $("#text").bind("focus",function(){
            $(this).val("sousou");    // 文本框获取焦点后value值为 sousou
            $(this).blur();        // 使文本框不可用
        });
        // 检测文本输入
        $("#tijiao").bind("click",function(){
            var a = $("input[name=inputText]");
                $("input[name=inputText]").each(function(){
        
                    if($(this).val() == ''){
                        $(this).css({"background":"pink","border-color":"red"});
                    }else {
                        $(this).css({"background":"green","border-color":"green"});
                    }
                });    
        });
        
        // 左右添加
        $("#right").bind("click",function(){
            $("#se>option:selected").appendTo($("#se2"))
        });
        $("#left").bind("click",function(){
            $("#se2>option:selected").appendTo($("#se"))
        });
    });
  • 相关阅读:
    mysql面试题
    Excel下载打不开
    Linux安装jdk1.8和配置环境变量
    Linux压缩、解压文件
    Linux常用命令1
    VMware下载安装及CentOS7下载安装
    ueditor的简单配置和使用
    linux的tomcat服务器上部署项目的方法
    TortoiseSVN客户端的使用说明
    CentOS 6.5系统上安装SVN服务器
  • 原文地址:https://www.cnblogs.com/cfb513142804/p/4279108.html
Copyright © 2011-2022 走看看