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="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总结的更多相关文章
- 常用js方法
function dateGetter(name, size, offset, trim) { offset = offset || 0; return function (date) { var v ...
- 常用JS正则表达式
常用JS正则表达式 收集一些常用的JavaScript正则表达式匹配规则,比如匹配电话号码.Email.中文字符.身份证号.邮编.QQ号.过滤空白行.匹配特定数字等.觉得这玩意是很有用的,只不过自己水 ...
- 常用js方法整理common.js
项目中常用js方法整理成了common.js var h = {}; h.get = function (url, data, ok, error) { $.ajax({ url: url, data ...
- 原生JS研究:学习jquery源码,收集整理常用JS函数
原生JS研究:学习jquery源码,收集整理常用JS函数: 1. JS获取原生class(getElementsByClass) 转自:http://blog.csdn.net/kongjiea/ar ...
- 项目中常用js方法整理common.js
抽空把项目中常用js方法整理成了common.js,都是网上搜集而来的,大家一起分享吧. var h = {}; h.get = function (url, data, ok, error) { $ ...
- 常用js正则表达式大全
常用js正则表达式大全.一.校验数字的js正则表达式 1 数字:^[0-9]*$ 2 n位的数字:^\d{n}$ 3 至少n位的数字:^\d{n,}$ 4 m-n位的数字:^\d{m,n}$ 5 零和 ...
- api日常总结:前端常用js函数和CSS常用技巧
我的移动端media html{font-size:10px} @media screen and (min-width:321px) and (max-width:375px){html{font- ...
- web前端关于html转义符的常用js函数
web前端关于html转义符的常用js函数 //去掉html标签 function removeHtmlTab(tab) { return tab.replace(/<[^<>]+? ...
- 基础常用JS函数和语法
100多个基础常用JS函数和语法集合大全 来源:http://www.cnblogs.com/hnyei/p/4605103.html 网站特效离不开脚本,javascript是最常用的脚本语言,我 ...
随机推荐
- 如何在 Ubuntu 中安装 Node.js
在终端中执行以下命令: sudo apt-get install python-software-properties python g++ make sudo add-apt-repository ...
- Theme.AppCompat.Light的解决方法
style name=”AppBaseTheme” parent=”Theme.AppCompat.Light” 改为 改为 style name=”AppBaseTheme” parent=”and ...
- iOS - UITextView放在自定义cell里面-自适应高度
textView放在自定义cell里面-自适应高度 1,textView有个属性 scrollEnabled 要设置为NO; 2,设置tableview的时候 添加这两行代码: self.tabl ...
- KindEditor上传图片无法使用绝对路径
之前百度,一直查到的都是urlType使用domain,但是根本没有效果.想着去插件代码里面看,但是实在看不下去了. 最后还是百度去了.然后查到下面的一个方法.直接将其中的某部分代码注释到就好了.具体 ...
- 日记整理---->2017-05-14
学习一下知识吧,好久没有写博客了.如果他总为别人撑伞,你又何苦非为他等在雨中. 学习的知识内容 一.关于base64的图片问题 byte[] decode = Base64.base64ToByteA ...
- 怎样用SQL语句查看查询的性能指标
一.SET STATISTICS IO (有关TSQL语句查询所产生的磁盘活动量) 扫描计数:在查询中涉及到的表被访问的次数: 逻辑读取:从数据缓冲中读取的数据页数: 物理读取:从物理磁盘中往缓冲读 ...
- 题目1040:Prime Number(第k个素数)
题目链接:http://ac.jobdu.com/problem.php?pid=1040 详解链接:https://github.com/zpfbuaa/JobduInCPlusPlus 参考代码: ...
- LeetCode 35 Search Insert Position(查找插入位置)
题目链接: https://leetcode.com/problems/search-insert-position/?tab=Description 在给定的有序数组中插入一个目标数字,求出插入 ...
- 23种设计模式之策略模式(Strategy)
策略模式是一种对象的行为型模式,定义一系列算法,并将每一个算法封装起来,并让它们可以相互替换.策略模式比算法独立于使用它的客户而变化,其目的是将行为和环境分隔,当出现新的行为时,只需要实现新的策略类. ...
- 安装 SQL SERVER MsiGetProductInfo 无法检索 Product Code 1605错误 解决方案
重装数据库服务器上的SQL SERVER 2008 上遇到了以下问题 标题: SQL Server 安装程序失败. SQL Server 安装程序遇到以下错误: MsiGetProductInfo 无 ...