
js
l_degege
这个作者很懒,什么都没留下…
展开
-
js定义字符串
使用双引号或单引号包含任意长度的文本。示例1任何被引号包含的文本都被称为字符串型数据。var s = "true"; //把布尔值转换为字符串var s = "123"; //把数值转换为字符串var s = "[1,2,3]"; //把数组转换为字符串var s = "{x : 1; y : 2}"; //把对象转换为字符串var s = "console.log('Hello,World')"; //把可执行表达式转换为字符串示例2单引号和双引号可以配合使用,定义转载 2021-03-17 09:32:50 · 778 阅读 · 0 评论 -
js获取当前页面的地址和端口_url
console.log(window.location.origin)注:https://blog.youkuaiyun.com/pengShuai007/article/details/78357238转载 2020-12-18 17:49:50 · 2215 阅读 · 1 评论 -
div添加一个点击事件(绑定点击事件)
1、HTML onclick 事件属性https://www.feiniaomy.com/post/339.htmlhttps://www.w3school.com.cn/tags/event_onclick.asp2、JavaScript 详说事件机制之冒泡、捕获、传播、委托<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>转载 2020-08-18 13:54:08 · 12835 阅读 · 0 评论 -
js中对象简写
1、简写前let myModule11 = { data: 'module11', foo:function foo() { console.log(`foo() ${this.data}`) }, bar:function() { console.log(`bar() ${this.data}`) }}2、简写后let myModule = { data: 'module1', foo() {原创 2020-07-28 15:32:32 · 2257 阅读 · 0 评论 -
html中使用js、jQuery展示页面小结
1、ajax$.ajax();{ url:'', type:'post', data:{'name':'zs','age':17}, dataType:'json', success:function (data) { // body... }}2、div标签赋值$("#id").html()="test"; //或者 $("#id").html("test"); jquery 给span 赋值 $('#hiddenNote').text(‘ge转载 2020-06-29 10:53:08 · 627 阅读 · 0 评论 -
html页面中文乱码处理
1.服务器返回的字符是GBK,引用的js中有中文 确认和取消,显示乱码2.解决:设置js的编码格式 charset="UTF-8" ,最好在js后面加版本号,避免缓存注:https://blog.youkuaiyun.com/love__coder/article/details/6617338转载 2020-06-28 17:38:45 · 174 阅读 · 0 评论 -
checkbox根据id动态赋值
1、html <form id="myform" method="post" action="/layui/front_form_sub2"> <input type="text" id="name"><br> <input type="checkbox" id="a" name="coffee" value="A">A<br /> <input type="checkbox" id="b" name="coffe原创 2020-06-15 17:53:40 · 1035 阅读 · 0 评论 -
jquery中checkbox赋值
1、html<input type="checkbox" id="a" name="coffee" value="A">A<br />2、js$("input[id='a']").attr("checked","checked");$("#a").attr("checked","checked");注:以上均可赋值https://blog.youkuaiyun.com/u011287511/article/details/54311038...转载 2020-06-13 16:59:18 · 1206 阅读 · 1 评论 -
js字符串转换为json对象JSON.parse()及将json对象转为json字符串JSON.stringify()
1、https://www.cnblogs.com/taiyonghai/p/5663541.htmlhttps://my.oschina.net/jast90/blog/386820转载 2020-06-13 17:04:26 · 893 阅读 · 0 评论 -
js 字符串去空格方法
str = str.replace(/\s*/g,"");注:https://www.cnblogs.com/a-cat/p/8872498.htmlhttps://www.cnblogs.com/jun-qi/p/11057421.html转载 2020-06-13 10:44:11 · 267 阅读 · 0 评论 -
ajax请求上传数组
1.ajax提交添加”traditional:true”参数注:https://blog.youkuaiyun.com/loster_Li/article/details/80916279 https://blog.youkuaiyun.com/ojackhao/article/details/24580437转载 2020-05-24 23:54:00 · 394 阅读 · 0 评论 -
weui.picker 乱码处理
注:https://www.cnblogs.com/iLoveMyD/p/11081625.html转载 2020-05-22 11:09:33 · 527 阅读 · 0 评论 -
js 取小数整数部分
1.丢弃小数部分,保留整数部分js:parseInt(7/2)2.向上取整,有小数就整数部分加1js: Math.ceil(7/2)3,四舍五入.js: Math.round(7/2)4,向下取整js: Math.floor(7/2)注:https://www.cnblogs.com/diony/p/8630789.html...转载 2020-02-19 20:59:51 · 890 阅读 · 0 评论 -
js中的常见问题
1、js的数据类型有那些JavaScript 语言的每一个值,都属于某一种数据类型。JavaScript 的数据类型,共有六种。数值(number)、字符串(string)、布尔值(boolean)、undefined、null、对象(object)通常,数值、字符串、布尔值这三种类型,合称为原始类型(primitive type)的值,即它们是最基本的数据类型,不能再细分了。对象则称为...转载 2020-02-06 10:45:58 · 235 阅读 · 0 评论 -
js中执行顺序理解
1、https://blog.youkuaiyun.com/chen_zw/article/details/18502937页面加载过程中,浏览器会对页面上或载入的每个js代码块(或文件)进行扫描,如果遇到定义式函数,则进行预处理(类似于C等的编译),处理完成之后再开始由上至下执行;遇到赋值式函数,则只是将函数赋给一个变量,不进行预处理(类似1中变量必须先定义后引用的原则),待调用到的时候才进行处理。2...转载 2020-02-05 12:19:45 · 214 阅读 · 0 评论 -
ajax上传多行数据及数组循环添加对象
function pay(collectingCompanyId){ var aCount=$("#actualCount").text(); var aMoney=$("#actualMoney").text(); var html = "<div style='padding:10px;'>摘要:<input type='text' id='tit...原创 2018-06-04 12:44:54 · 3215 阅读 · 0 评论 -
js分割字符串
var str="2,2,3,5,6,6"; //这是一字符串var strs= new Array(); //定义一数组strs=str.split(","); //字符分割注:https://www.cnblogs.com/chenlove/p/8818067.html转载 2019-12-16 15:39:42 · 554 阅读 · 0 评论 -
jq 点击事件 调用
1、点击事件<i class="layui-icon layui-icon-search" id="search"></i>$('#search').bind("click",function(){ //action});2、在其他方法中调用,使用$('#search').click();eg: window.onDel = fun...原创 2019-12-10 19:52:32 · 1553 阅读 · 0 评论 -
js判断数据类型(如数组)及数组操作函数
一、js判断类型Object.prototype.toString可以看出一个值到底是什么类型。Object.prototype.toString.call(2) // "[object Number]"Object.prototype.toString.call('') // "[object String]"Object.prototype.toString.call(true)...转载 2019-12-09 09:53:38 · 261 阅读 · 0 评论 -
js日期格式化写法及获取当前日期年月日、上一月
注:https://blog.youkuaiyun.com/qq_39985511/article/details/80031674转载 2019-05-29 19:42:23 · 1789 阅读 · 0 评论 -
js计算时间差写法
注:https://blog.youkuaiyun.com/niu_hao/article/details/8256745转载 2019-05-29 19:40:44 · 1480 阅读 · 0 评论 -
js获取字符串索引indexOf用法
https://www.cnblogs.com/dyqblog/p/5431824.html转载 2019-05-30 15:57:54 · 11506 阅读 · 0 评论 -
js中字符串全部替换函数(正则表达式)
str.replace(/需要替换的字符串/g,"新字符串")eg:"yyyy-MM-dd-hh-mm-ss".replace(/-/g,"/")结果如下:"yyyy/MM/dd/hh/mm/ss"eg:将反斜杠替换成斜杠alert($('#accept').combobox('getValue').replace("upload","doc").replace(/\...转载 2019-05-27 16:25:54 · 9287 阅读 · 0 评论 -
js大括号的理解
var myData={a:1};表示定义了一个对象,对象有属性和值。注:https://www.cnblogs.com/chayan/p/5792862.html转载 2019-03-25 09:11:25 · 1864 阅读 · 0 评论