【Tip】JavaScript
『JavaScript』
『引用网络资源』
JQuery
1 | < script src="http://code.jquery.com/jquery-latest.js"></ script > |
Vue
1 | < script src="https://unpkg.com/vue/dist/vue.js"></ script > |
『基础』
【随机数】
生成 [n~m] 范围(含起止数)的随机数
1 | Math.random()*(m-n)+n |
『字符串』
【替换】
1 | str= str.replace( new RegExp( '_REPLACE_' , 'g' ), '_NEW_' ); |
『功能函数』
【setInterval停止】
1 2 3 4 5 | var _num=3; var _timer=setInterval( function (){ console.log(_num--); if (_num<=0) clearInterval(_timer); // 满足条件,清除定时器 },1000); |
『JQuery』
『控件操作』
【select】
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | //【获取Select】 //------------------------------ //获取select选中的text : $( "#ddlSelect" ).find( "option:selected" ).text(); //获取select选中的value: $( "#ddlSelect" ).val(); //获取select选中的索引: $( "#ddlSelect" ).get(0).selectedIndex; //【设置select】 //------------------------------ //设置select选中的索引: $( "#ddlSelect" ).get(0).selectedIndex=index; //index为索引值 //设置select选中的value: $( "#ddlSelect" ).val( "Normal" ); $( "#ddlSelect" ).get(0).value = value; $( "#ddlSelect" ).attr( "value" , "Normal" ); //设置text为pxx的项选中 $( "#ddlSelect" ).find( "option[text='pxx']" ).attr( "selected" , true ); //【清空 Select】 //------------------------------ $( "#ddlSelect" ).empty(); |
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步