诱红楼封面大图:常用js
来源:百度文库 编辑:九乡新闻网 时间:2024/05/03 05:37:46
1. js实现浮点数位数的保留
方法1: /**
*v表示要转换的值
*e表示要保留的位数
*/
function round(v,e){
var t=1;
for(;e>0;t*=10,e--);
for(;e<0;t/=10,e++);
return Math.round(v*t)/t;
}使用方法:value = round(value,2);//保留2位小数,并且可以格式化数字,在数字过大时不会出现科学计数法。方法2:value=parseFloat(value).toFixed(2).toString();//保留2位小数,并且可以格式化数字,在数字过大时不会出现科学计数法。
2. js日历控件的使用
引进js文件:使用:1) 使用默认格式:及yyyy-MM-dd2) 指定格式:如:yyyy-MM-dd或yyyy-MM或yyyy-MM-dd HH:mm:ss说明:skin:'whyGreen'设定控件的样式class="Wdate" 设定输入框到的样式注:使用的时候需要日历控件的js文件的支持。
2. 关闭子窗口刷新父窗口
父窗口写法: window.open("...");void 0;子窗口写法: 执行完其他的操作(比如:提交表单form.submit,或window.location.href=""), 执行:window.opener.location=window.opener.location; this.close();
3. 将秒转换成小时分钟秒的js
function formatSeconds(value) {
var theTime = Number(value);
var theTime1 = 0;
var theTime2 = 0;
//alert(theTime);
if(theTime > 60) {
theTime1 = Number(theTime/60);
theTime = Number(theTime%60);
//alert(theTime1+"-"+theTime);
if(theTime1 > 60) {
theTime2 = Number(theTime1/60);
theTime1 = Number(theTime%60);
}
}
var result = ""+theTime+"s";
if(theTime1 > 0) {
result = ""+parseInt(theTime1)+"m"+result;
}
if(theTime2 > 0) {
result = ""+parseInt(theTime2)+"h"+result;
}
return result;
}
常用js
js常用的小技能
常用的JS脚本代码
JS简单验证常用格式
站长常用的200个js代码
常用js跳转页面方法大全,onClick,history,location
常用网页广告代码全集-js广告代码
九款常用的JS代码高亮工具
常用js跳转页面方法大全,onClick,history,location <转载篇> -...
json.js
JS 日历
采穗圃js
JSON.js test
js 确认对话框
JS操作cookie
Js与CSS工具
Node.js binaries download
js showModalDialog参数传递
js 菜单标签示例
node.js入门
面试中的自我介绍JS
js正则大全
js客户端校验
js修改css详解