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="width: 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');
});

idong常用js总结的更多相关文章

  1. 常用js方法

    function dateGetter(name, size, offset, trim) { offset = offset || 0; return function (date) { var v ...

  2. 常用JS正则表达式

    常用JS正则表达式 收集一些常用的JavaScript正则表达式匹配规则,比如匹配电话号码.Email.中文字符.身份证号.邮编.QQ号.过滤空白行.匹配特定数字等.觉得这玩意是很有用的,只不过自己水 ...

  3. 常用js方法整理common.js

    项目中常用js方法整理成了common.js var h = {}; h.get = function (url, data, ok, error) { $.ajax({ url: url, data ...

  4. 原生JS研究:学习jquery源码,收集整理常用JS函数

    原生JS研究:学习jquery源码,收集整理常用JS函数: 1. JS获取原生class(getElementsByClass) 转自:http://blog.csdn.net/kongjiea/ar ...

  5. 项目中常用js方法整理common.js

    抽空把项目中常用js方法整理成了common.js,都是网上搜集而来的,大家一起分享吧. var h = {}; h.get = function (url, data, ok, error) { $ ...

  6. 常用js正则表达式大全

    常用js正则表达式大全.一.校验数字的js正则表达式 1 数字:^[0-9]*$ 2 n位的数字:^\d{n}$ 3 至少n位的数字:^\d{n,}$ 4 m-n位的数字:^\d{m,n}$ 5 零和 ...

  7. api日常总结:前端常用js函数和CSS常用技巧

    我的移动端media html{font-size:10px} @media screen and (min-width:321px) and (max-width:375px){html{font- ...

  8. web前端关于html转义符的常用js函数

    web前端关于html转义符的常用js函数 //去掉html标签 function removeHtmlTab(tab) { return tab.replace(/<[^<>]+? ...

  9. 基础常用JS函数和语法

    100多个基础常用JS函数和语法集合大全  来源:http://www.cnblogs.com/hnyei/p/4605103.html 网站特效离不开脚本,javascript是最常用的脚本语言,我 ...

随机推荐

  1. Windows下POSIX线程编程(pThread)环境搭建

    系统: Windows 编辑器:codeblocks13.12 1. 简介: Windows有一个叫 POSIX Threads for Win32 的开源项目给出了一个功能比较完善的Windows下 ...

  2. 【LeetCode OJ】Remove Element

    题目:Given an array and a value, remove all instances of that value in place and return the new length ...

  3. iOS使用TFHpple解析html

    iOS 开发中解析html 网上有很多写好的解析框架 今天就来讲一下如何用框架TFHpple来解析html 使用TFHpple解析html github地址:https://github.com/to ...

  4. EventHandler 与常见的.Net预定义委托

    看着下面这两句事件定义及激发忽然有点不明白了, public event EventHandler<ExternalDataEventArgs> Submit; Submit(null, ...

  5. 【.NetCore学习】ASP.NET Core EF Core2.0 DB First现有数据库自动生成实体Context

    主要参考微软官方文档 https://docs.microsoft.com/en-us/ef/core/get-started/aspnetcore/existing-db Microsoft .NE ...

  6. GDI+ 和GDI

    GDI:Graphics Device Interface,即图形设备接口,是Windows API的一个重要组成部分.它是Windows图形显示程序与实际物理设备之间的桥梁,GDI使得用户无需关心具 ...

  7. 重载i++,++i操作符

    #include <iostream> using namespace std; class Time { public: Time(){min=;sec=;} Time(int m,in ...

  8. smarty直接在模板中格式化时间的方法

    smarty提供了一个获取时间戳的方法: <%$smarty.now%> 使用该方法获取到当时的时间戳之后,使用格式化修饰符data-format进行修饰: <%$smarty.no ...

  9. Python Tkinter 学习成果:点歌软件music

    笔者工作业余时间也没什么爱好,社交圈子也小,主要娱乐就是背着自己带电瓶的卖唱音响到住地附近找个人多的位置唱唱KtV. 硬件上点歌就用笔记本电脑,歌曲都是网上下载的mkv格式的含有两个音轨的视频.因此点 ...

  10. SOS does not support the current target architecture解决方法

    客户提交一个dump文件,WinDbg加载时出现大量WARNING,加载对应版本的SOS后执行相应命令提示"SOS does not support the current target a ...