• idong常用js总结


    1.判断屏幕高度

    $(document).ready(function() {
        $("#left").height($(window).height());
        $("#main").height($(window).height() - 80);
        //t = (screen.height - 30)  
    });

    2.下拉框选中内容替换原有文字(类似城市切换)

    $(".display ul li").click(function() {
                $(".display").hide();
                $(".xzsj span").empty().prepend($(this).text());
    });

    3.简单开关按钮

         <p class="sexp" style=" 150px">
                <span class="sex boy activesex">男</span>
                <span class="sex">女</span>
            </p>

      $('.sex').click(function(){
                        $(this).removeClass('activesex');
                        $(this).addClass('activesex').siblings('span').removeClass('activesex');
                    })
      3.增加id

      $(".tab ul li").click(function(){
             $(".tab ul li").eq($(this).index()).attr('id',"active_tab").siblings().removeAttr('id','active_tab');
           //另一种方法: $("div").eq($(".tab li").index(this)).addClass("on").siblings().removeClass('on');

            });

    4.children parent用处多多

    $('.boxlist1').mouseover(function(){
       $(this).children('.listdetail').children('.rightbj').css('display','block');
    });
    $('.boxlist1').mouseout(function(){
         $(".rightbj").hide();
    });

        $('.hover_bj').mouseover(function(){
                        $(this).children('.xiugai').css('display','block');
                    });
                    $('.hover_bj').mouseout(function(){
                        $(this).children('.xiugai').css('display','none');
                        
                    })

    5.判断

     if ($(this).text()=="月报") {
          $(".selectzcfz").show();
             
         } else{
              $(".selectzcfz2").show();
              $(".selectzcfz").hide();
         }
    6.   判断当前样式如果是a,则b隐藏,如果是b,则a隐藏

        <script>
                    $(function(){
                        $('a').click(function(){
                            if($(this).hasClass('close')){
                                $(this).css('display','none');
                                $(this).siblings('a').css('display','inline');
                                
                            }else if($(this).hasClass('open')){
                                $(this).css('display','none');
                                $(this).siblings('a').css('display','inline');
                            }
                        })
                    })
                </script>

    7.切换按钮

    $('.yiqiyong').click(function() {
        $(this).toggleClass('yiqiyong');
        $(this).toggleClass('yijinyong');
    });

  • 相关阅读:
    JAVA基础知识|HTTP协议-两个特性
    JAVA基础知识|TCP/IP协议
    Spring Cloud|高可用的Eureka集群服务
    Hadoop环境搭建|第四篇:hive环境搭建
    C#中Func与Action的理解
    C# lambda表达式
    WPF ControlTemplate
    sublime text3插件安装及使用
    Dev Express之ImageComboBoxEdit,RepositoryItemImageComboBox使用方式
    SQL查询结果增加序列号
  • 原文地址:https://www.cnblogs.com/zhouyx/p/4465143.html
Copyright © 2020-2023  润新知