随笔分类 -  HTML,CSS,JS

1 2 下一页
防抖和节流
摘要:防抖 当事件被触发时,设定一个周期延迟执行动作,若期间又被触发,则重新设定周期,直到周期结束,执行动作 function debounce(func, delay) { let timer = null; return function (...arguments) { clearTimeout(t 阅读全文
posted @ 2022-04-26 11:59 jzfan
insert-text-at-cursor-in-a-content-editable-div
摘要:https://stackoverflow.com/questions/2920150/insert-text-at-cursor-in-a-content-editable-div function insertTextAtCaret(text) { var sel, range; if (win 阅读全文
posted @ 2021-11-29 10:54 jzfan
Constant width to height ratio
摘要:<div class="constant-width-to-height-ratio"></div> .constant-width-to-height-ratio { background: #9C27B0; width: 50%; } .constant-width-to-height-rati 阅读全文
posted @ 2021-08-27 12:01 jzfan
async/await error
摘要:function smartPromise(promise){ return promise.then(res=>([null,res])).catch((e)=>([e,null])); } async function task(){ const [errorA,fileA] = await s 阅读全文
posted @ 2021-03-25 18:36 jzfan
JS精准运算
摘要:function accAdd(arg1, arg2) { var r1, r2, m; try { r1 = arg1.toString().split(".")[1].length; } catch (e) { r1 = 0; } try { r2 = arg2.toString().split 阅读全文
posted @ 2020-11-13 10:49 jzfan
手写JS
摘要:取整 var a = ~~2.33 //(四舍五入) var b= 2.55 | 0//上取整 var c= 2.33 >> 0//下取整 金钱格式化:1234567890 --> 1,234,567,890 var test1 = '1234567890' var format = test1.r 阅读全文
posted @ 2020-10-12 14:17 jzfan
js groupBy
摘要:function groupBy( array , id ) { let groups = {}; array.forEach( function( o ) { let group = JSON.stringify( o[id] ); groups[group] = groups[group] || 阅读全文
posted @ 2020-09-23 11:04 jzfan
js rand(min, max)
摘要:rand(min, max) { return parseInt(Math.random() * (max - min + 1) + min, 10); }, 阅读全文
posted @ 2020-07-01 10:19 jzfan
h5 video
摘要:<div class="relative"> <video class="w-full h-full object-fill" id="ckplayer_a1" :src="url" x5-video-player-type="h5" preload="metadata" playsinline=" 阅读全文
posted @ 2020-04-27 21:11 jzfan
微信 分享
摘要:var link = location.href $.ajax({ url: 'your_url', //后台给你提供的接口 type: 'GET', data: { url: link }, async: true, dataType: 'json', success: function(data 阅读全文
posted @ 2020-04-02 00:26 jzfan
font size
摘要:动态调整font-size 阅读全文
posted @ 2019-10-14 10:04 jzfan
tailwind + vue
摘要:在根目录下生成 tailwind 配置文件 npx tailwind init --full 修改 package.json 的 postcss 选项 "postcss": { "plugins": { "tailwindcss": "./tailwind.config.js", "autoprefixer": {} } }, ... 阅读全文
posted @ 2019-06-04 21:52 jzfan
仿百度查询
摘要:JS HTML 阅读全文
posted @ 2018-03-05 17:56 jzfan
baidu jsonp
摘要:var s = "https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su?wd=132&json=1"; var fetchJsonp = function(url){ var body = document.getElementsByTagName('body')[0]; //插入一个s... 阅读全文
posted @ 2018-03-05 17:54 jzfan
template string
摘要:let name = 'Bar' let template = ` ${name} `.trim(); 阅读全文
posted @ 2017-12-09 14:59 jzfan
select2 / dropzone
摘要:select2 / dropzone 阅读全文
posted @ 2017-02-08 12:13 jzfan
video
摘要: 阅读全文
posted @ 2016-08-24 17:01 jzfan
faker image
摘要:http://placehold.it http://placekitten.com/g/200/300 带文字 https://placeholdit.imgix.net/~text?txtsize=50&txt=logo&w=110&h=110&txttrack=0 cat http://pla 阅读全文
posted @ 2016-06-29 17:37 jzfan
truncate
摘要:css php blade @truncate($card->title, 20) 阅读全文
posted @ 2016-06-16 05:02 jzfan

1 2 下一页