This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.onkeydown=function() {//捕捉回车 | |
if (event.keyCode==13) { | |
checkFormValidate(); | |
return false; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
goog.events.listen(element, goog.events.EventType.KEYPRESS, function(a) { | |
if(a.keycode === 13) { | |
doSomething(); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Format Date | |
* usage: | |
* date2str(new Date(seconds*1000),"MM-dd hh:mm"); | |
*/ | |
date2str = function(x,y) { | |
var z = {M:x.getMonth()+1,d:x.getDate(),h:x.getHours(),m:x.getMinutes(),s:x.getSeconds()}; | |
y = y.replace(/(M+|d+|h+|m+|s+)/g,function(v) { | |
return ((v.length>1?"0":"")+eval('z.'+v.slice(-1))).slice(-2) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function (){ | |
var times = 0; | |
//滚动条到网页头部的 高度,兼容ie,ff,chrome | |
var top = document.documentElement.scrollTop + document.body.scrollTop; | |
//网页的高度 | |
var textheight = document.body.offsetHeight; | |
// 网页高度-top-当前窗口高度 | |
if (textheight - top - window.innerHeight <= 50) { | |
if (times >= 20) { | |
return; //控制最大只能加载20次 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div ng-app> | |
<h2>Todo</h2> | |
<div ng-controller="QuarterController"> | |
<select name="quarter" ng-model="Quarter" | |
ng-options="obj.value as obj.text for obj in [ | |
{'value': 1,'text' : 'Q1'},{'value':2,'text':'Q2'},{'value':3,'text':'Q3'},{'value':4,'text':'Q4'}]"> | |
</select> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//---- controller.js ---- | |
$scope.pageNum = null; | |
$scope.currentPage = 0; | |
$scope.pageSize = 10; | |
/* get previous page data */ | |
$scope.getPrevPage = function() { | |
$scope.currentPage = $scope.currentPage - 1; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
第一种方法: | |
var timestamp = Date.parse(new Date()); | |
结果:1280977330000 | |
第二种方法: | |
var timestamp = (new Date()).valueOf(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//使用return false来禁用 form的默认submit事件。 | |
<form method="POST" action="" id="search-form"> | |
<input type="text" name="keywords" /> | |
<input type="submit" value="Search" id="sButton" onclick="loadXMLDoc('file.xml')" /> | |
</form> | |
<script> | |
window.onload = function() { | |
document.getElementById("search-form").onsubmit = function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<A href="javascript:void(0)">click me</a> | |
//javascript:void(0) 不返回的意思 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(".location").bind("input", function() { | |
var $this = $(this); | |
var delay =250; // delay after last input | |
clearTimeout($this.data('timer')); | |
$this.data('timer', setTimeout(function(){ | |
$this.removeData('timer'); | |
doSomething(); | |
}, delay)); | |
}); |
OlderNewer