69.(javascript)控制字符串长度
摘要:// length function function subLength(obj, len) { if (obj.value.length > len) { obj.value = obj.value.substr(0, len); } } onkeyup="subLength(this,50)"
阅读全文
posted @
2021-10-26 11:11
♩♪♫♬
阅读(125)
推荐(0)
57.(javascript)Date() 函数
摘要:1.定义日期型变量:var today = new Date(); 2.日期函数列表:dateObj.getTime()得到时间,dateObj.getYear()得到年份,dateObj.getFullYear()得到四位的年份,dateObj.getMonth()得 到月份,dateObj.ge
阅读全文
posted @
2021-07-24 09:51
♩♪♫♬
阅读(92)
推荐(0)
56.(javascript)刷新当前页面
摘要:window.location.href = window.location.href;
阅读全文
posted @
2021-07-24 09:46
♩♪♫♬
阅读(60)
推荐(0)
55.(javascript)删除数组尾部元素
摘要:一个简单的用来清空或则删除数组尾部元素的简单方法就是改变数组的length属性值 const arr = [11, 22, 33, 44, 55, 66]; // truncanting arr.length = 3; console.log(arr); //=> [11, 22, 33] // c
阅读全文
posted @
2021-07-23 23:32
♩♪♫♬
阅读(241)
推荐(0)
54.(javascript)用JSON来序列化与反序列化
摘要:var person = {name :'Saad', age : 26, department : {ID : 15, name : "R&D"} }; var stringFromPerson = JSON.stringify(person); /* stringFromPerson 结果为 "
阅读全文
posted @
2021-07-23 23:23
♩♪♫♬
阅读(57)
推荐(0)
19.(javascript)如何保留小数位数为四位
摘要:var ticketPrice = parseFloat(str).toFixed(4); //使用toFix()方法保留四位小数
阅读全文
posted @
2021-07-21 00:04
♩♪♫♬
阅读(412)
推荐(0)
15.(javascript)table的tr行的显示和隐藏功能
摘要:<table> <tr id = "bookInfo"> <td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td> </tr> </table> $("#bo
阅读全文
posted @
2021-07-20 22:26
♩♪♫♬
阅读(199)
推荐(0)
12.(javescript)给指定html标签元素$(""),添加样式addClass()或者删除样式 removeClass()
摘要:var book = $("#bookName"); book.removeClass(); //删除样式class var newClass = "book-store"; book.addClass(newClass); //添加样式
阅读全文
posted @
2021-07-20 19:46
♩♪♫♬
阅读(62)
推荐(0)
11.(javescript)每间隔十秒刷新页面setInterval()循环函数调用
摘要:function getBookStatus() { $("#<%= this.hidBookStatus.ClientID%>").val($("#<%= this.ddlBookStatus.ClientID%> option:selected").val()); } setInterval(g
阅读全文
posted @
2021-07-20 19:29
♩♪♫♬
阅读(64)
推荐(0)
3.(javascript)decodeURICompnent解码后的加号问题
摘要:decodeURIComponent(q.replace(/\+/g, ""); 带全局标志/g,全局替换 无全局标志/g,只替换第一个匹配的返回结果字符串
阅读全文
posted @
2021-07-09 20:27
♩♪♫♬
阅读(175)
推荐(0)
1.(javascript)最多只能输入两位小数
摘要:function clearNoNum(obj){ obj.value = obj.value.replace(/[^\d.]/g,""); //清除“数字”和“.”以外的字符 obj.value = obj.value.replace(/\.{2,}/g,"."); //只保留第一个. 清除多余的
阅读全文
posted @
2017-08-01 10:18
♩♪♫♬
阅读(183)
推荐(0)