1 Star 0 Fork 0

两好三坏 / learnJavaScript

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
testJquery.html 3.82 KB
一键复制 编辑 原始数据 按行查看 历史
两好三坏 提交于 2017-06-03 11:17 . 1. add js animation
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>testJque</title>
<script src="jquery-3.2.0.min.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<!--<lable>labelBegin</lable>
<span id="foo:bar">哇哦</span>
<span id="foo[bar]">wocao</span>
<span id="foo.bar">握草</span>
<h1>hahaha</h1>
<h2> hahahahhahhaha</h2>
<h3>hshdadhauidhsuiahduishauifhuashdfuhsauifdh</h3>
<h4>hdsajiyfu8ghbjhiabuwieyagydfusiadjsahduisagfyusaidfsajfh</h4>
<div>
<h5>div 的 h1标签</h5>
<p>div 的 p 标签</p>
</div>-->
<!--<p>body 下的 p 标签</p>-->
<input type="text" name="" id="inputContent" value="点我输入文字" />
<label for="" id="changeTitle" onclick='checkAge("1993-03-16")'> 我会变身的</label>
<script type="text/javascript">
function parseDate(str) {
if(string(str.match(/^\d{4}[\-\/\s+]\d{1,2}[\-\/\s+]\d{1,2}$/))) {
return new Date(str.replace(/[\-\/\s+]/i, '/'));
} else if(str.match(/^\d{8}$/)) {
return new Date(str.substring(0, 4) + '/' + str.substring(4, 6) + '/' + str.substring(6));
} else {
return('时间转换发生错误!');
}
}
function GetAgeByBrithday(birthday) {
var age = -1;
var today = new Date();
var todayYear = today.getFullYear();
var todayMonth = today.getMonth() + 1;
var todayDay = today.getDate();
var birthday = parseDate(birthday);
if(parseDate(birthday) != '时间转换发生错误!') {
birthdayYear = birthday.getFullYear();
birthdayMonth = birthday.getMonth();
birthdayDay = birthday.getDate();
if(todayYear - birthdayYear < 0) {
alert("出生日期选择错误!");
} else {
if(todayMonth * 1 - birthdayMonth * 1 < 0) {
age = (todayYear * 1 - birthdayYear * 1) - 1;
} else {
if(todayDay - birthdayDay >= 0) { //alert(thisDay+'-'+brithd+"_ddd");
age = (todayYear * 1 - birthdayYear * 1);
} else {
age = (todayYear * 1 - birthdayYear * 1) - 1;
}
}
}
return age * 1;
} else {
return -1;
}
}// TODO 年龄小于18
function checkAge(params) {
var dateTmp = new Date();
var currentYears = dateTmp.getFullYear();
var currentMouths = dateTmp.getMonth()+1;
var currentDays = dateTmp.getDate();
var years = params.substring(0,4);
var mouths = params.substring(5,7);
var days = params.substring(8,11);
var age = 0;
if(currentMouths * 1 - mouths * 1 < 0) {
age = (currentYears * 1 - years * 1) - 1;
} else {
if(currentDays - days >= 0) {
age = (currentYears * 1 - years * 1);
} else {
age = (currentYears * 1 - years * 1) - 1;
}
}
return age;
}
$("#inputContent").bind('input propertychange',function(){
console.log($(this).val());
if ($(this).val().indexOf('昌吉市')>=0) {
alert('包含昌吉市')
}else{
}
});
// $("body>p").css('background-color','red');
// $("body>div>p").css('background-color','beige')
//包含特殊字符的 id, 需要使用 ' \\ ' 进行转意
//$('#foo\\:bar').text()
// console.log($('span').text());
// 一个有效的选择器,紧接着的下一个符合条件的选择器
// console.log($("lable +span"));
// 选择器
//$(":header").css('background',"aliceblue");
/**
* even 奇数选择器
* odd 偶数选择器
* eq(*),查找索引值为 *
* gt(*) ,查找索引值大于 * 的所有元素;;
* lt(*) ,查找索引值小于 * 的所有元素
* last 返回最后一个元素
* header 获取所有 h 级别的元素
* :contains(params) 包含 params 参数的元素
* empty 返回空元素
* :parent 返回含有子元素的元素
* :hidden 返回所有隐藏元素
* [] eg : $("div [id]") 0---> 选择 div下有对应 id 的元素
* [Attribute = vlaue] 查找属性值为 *** 的元素,并返回
* [Attribute ^= vlaue] 查找属性值开头包含value 的 元素,并返回
* [Attribute *= vlaue] 查找属性值包含value 的 元素,并返回
*/
</script>
</body>
</html>
JavaScript
1
https://gitee.com/SuQiankun/learnjavascript.git
git@gitee.com:SuQiankun/learnjavascript.git
SuQiankun
learnjavascript
learnJavaScript
master

搜索帮助