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是最常用的脚本语言,我 ...
随机推荐
- Python的Flask框架与数据库连接的教程
命令行方式运行Python脚本 在这个章节中,我们将写一些简单的数据库管理脚本.在此之前让我们来复习一下如何通过命令行方式执行Python脚本. 如果Linux 或者OS X的操作系统,需要有执行脚 ...
- C语言char*字符串数组和unsigned char[]数组的相互转换
#include <iostream> #include <string> using namespace std; void convertUnCharToStr(char* ...
- 开源项目:MMTweenAnimation
本文转载至 http://adad184.com/2015/04/14/opensource-mmtweenanimation/ 前言 MMTweenAnimation其实酝酿了有一段时间了 起因是对 ...
- 【变态问题】在发现“XXXX”类型前实体框架已使用默认 DbConfiguration 实例。
今天在调试MVC反射调用EF写的dll 一直报错如下: 在发现“VipHallDbConfiguration”类型前实体框架已使用默认 DbConfiguration 实例.“VipHallDbCon ...
- 【技术分享会】 @第六期 iOS开发基础
前言 iOS之前被称为 iPhone OS,是一个由苹果公司开发的移动操作系统. iOS的第一个版本是在2007年发布的,其中包括iPhone和iPod Touch. iOS开发工具:Xcode 运行 ...
- Esper学习之十一:EPL语法(七)
上一篇说到了EPL如何访问关系型数据库这种数据源,实际上别的数据源,比如:webservice.分布式缓存.非关系型数据库等等,Esper提供了统一的数据访问接口.然后今天会讲解如何创建另外一种事件类 ...
- 题目1457:非常可乐(广度优先遍历BFS)
题目链接:http://ac.jobdu.com/problem.php?pid=1457 详解链接:https://github.com/zpfbuaa/JobduInCPlusPlus 参考代码: ...
- 简单了解如何使用vue-router和vue-resource
我们先来看看vue-router 1.npm install vue-router --save 2.调用vue-router: 第一种方法: 直接在main.js中调用 import vueRout ...
- Dockerfile ,ADD详细解读
一.ADD指令 ADD指令的功能是将主机构建环境(上下文)目录中的文件和目录.以及一个URL标记的文件 拷贝到镜像中. 其格式是: ADD 源路径 目标路径 如: #test FROM ubunt ...
- locate命令的使用
使用locate命令,遇到了这样的情况:当前目录下有一个文件,而使用这个命令时却查找不到这个文件,上网查了一下,找到了原因,就在下面. 1. find find是最常见和最强大的查找命令,你可以用它找 ...