1、切割

1. a="ddd"       a.substr(0,1)

2、通过js找子代

document.getElementByClass("ddd").getElementByClass("ccc")

3、window.open

window.open( url,"n1","status=1, height:500, width:600, toolbar=0, resizeable=0");    #在当前也打开一个窗口,页面不刷新
window.open(url) #重新在开启一个窗口,之前的页面不刷新

window.opener使用

子页面要向父页面传值,只要在document前面加window.opener即可

window.opener.____  后面调用的父页面的方法

例子

父页面

<body>
<h1 id = "a">无所谓</h1>
<a href="#" onclick=a("http://www.baidu.com")>点我点我</a>
<script>
function xxxpopupCallback(text) {
document.getElementById('a').innerHTML = text; //找到标签吧值替换成用户传进来的值
}
function a(url) {
window.open( '/pop/', "n1","status=1, height:500, width:600, toolbar=0, resizeable=0");
{#window.open( url,"n1","status=1, height:500, width:600, toolbar=0, resizeable=0");#}
}
</script>
</body>

子页面 

<body>
<input type="text" name="user">
<button type="button" onclick="submit()">提交</button>
</body>
<script>
function submit() {
   方法一
window.opener.document.getElementById("a").innerText=document.getElementsByTagName("input")[0].value #直接找到父页面的标签,进行替换值
   方法二:
{#opener.xxxpopupCallback(document.getElementsByTagName("input")[0].value)#} #opener.xxxpopupCallback 调用父页面的xxxpopCallback 方法
 window.close()
}
</script>

  

4、删除列表中的某个值

思路1:直接在delete上添加一个id属性(需要被删除的元素的id),通过js可以获取这个值,通过ajax发送异步请求,成功后,直接在页面上用js将他删除掉。

思路2:使用a标签包含一个butten按钮

思路2:使用form表单发送请求post请求,使用js方法(在js中创建表单,或者直接用页面上现有的表单进行submit())。

5、定时器

<script>
//每隔1秒执行function()
intervalId = setInterval(function () {
console.log(4);
}, 1000); //2秒之后执行function(),执行一次
setTimeout(function () {
//清除定时功能
clearInterval(intervalId)
},2000)
</script>

  

6、JS和Jquery获取input框中的值

<input type='text' id = 'username>'
var text = $(''#username").val("ddd") //jquery 获取值
$('username').val("") //jquery 设置值
var name = document.getElementById("CSDN_NAME").value //js获取值

  

7、数组的filter

var a = [1,2]
a.filter(res=>{return false}) -->a = []
a.filter(res=>{return true}) -->a = [1,2]

  

const accessedRouters = asyncRouterMap.filter(route => {
// console.log(route);
if (hasPermission(route)) {
if (route.children && route.children.length) {
route.children = filterAsyncRouter(route.children);
}
return true;
}
return false;
});

  

前端js/vue等的一些技巧

从后端取出来的数据,可以适当的对他进行编辑,比如添加一些字段show:true,方便自己操作

js----常用功能的更多相关文章

  1. JS 常用功能收集

    JS 常用效果收集 1. 回到顶部>>    爱词霸

  2. js 常用功能实现(函数)

    1.10 个短小实用的代码片段 :https://www.jianshu.com/p/3ef822ec5a63 2.js常用函数  : https://www.cnblogs.com/wangyuyu ...

  3. js常用功能汇总

    var Utils = function() { this.Tools; this.ui; }; Utils = new Utils(); Utils.prototype.Tools = { year ...

  4. js - 常用功能方法汇总(updating...)

    一.查值的类型(可用于拷贝) /* * @Author: guojufeng@ * @Date: 2017-12-20 15:07:06 * @purpose 获取一个值的类型 * @param {v ...

  5. JS常用功能

    1.字符串转Json var json='[{"id":0,"text":"ddddd"},{"id":1," ...

  6. js常用功能总结

    1,手机号的校验 //手机号的判断 function checktel() { //手机号不为空,格式校验 var tel = $(".uidbtp").val(); if(tel ...

  7. Hbuilder常用功能汇总

    引用 样式表: mui.min.css Js:mui.min.js 常用功能 获取页面 var webView=plus.webview.currentWebview();//获取当前页 var we ...

  8. Google Chrome调试js代码,开发者工具之调试工具常用功能

    参考:Google Chrome调试js代码-http://www.open-open.com/lib/view/open1384785324165.html 重点:左下角一个{}括号图标按钮用于把杂 ...

  9. 160229-01、web页面常用功能js实现

    web页面常用功能js实现   1.网页未加载时弹出新窗口 <body onunload="window.open('http://www.a68.cn');">< ...

  10. es6常用功能与异步详解(JS高级面试题)

    callback hell方法的使用 可读性不友好 function loadImg(src,callback,fail){ var img = document.createElement('img ...

随机推荐

  1. 微信小程序之内嵌网页(webview)

    设置权限 要在小程序中访问外部网页,需要先设置允许访问的业务网站的域名.让我们先登录小程序平台管理后台页面,进入“设置” => "开发设置",可以看到这边多出来了一块“业务域 ...

  2. js中创建数组,并往数组里添加元素

    数组的创建 var arrayObj = new Array(); //创建一个数组 var arrayObj = new Array([size]); //创建一个数组并指定长度,注意不是上限,是长 ...

  3. javascript/ajax和php 进阶 之 项目实战

    1,使用异步思想做一个下拉列表,能够选择和展示数据库中对应的信息. 1,事件知识:所有的事件可参照:https://www.jb51.net/html5/459444.html 2,js中this补充 ...

  4. Houdini OpenCL

    SOP: simple moveKernel #include "interpolate.h" float lerpConstant( constant float * in, i ...

  5. ARMCC和GCC编译ARM代码的软浮点和硬浮点问题 【转】

    转自:http://houh-1984.blog.163.com/blog/static/31127834201211112129167/ 本文介绍了ARM代码编译时的软浮点(soft-float)和 ...

  6. MySQL查看表的索引【转】

    查看表的索引: show index from table_name(表名) 结果列表中各字段的含义: · Non_unique 如果索引不能包括重复词,则为0.如果可以,则为1. · Key_nam ...

  7. HAProxy详解(二):HAProxy基础配置与应用实例

    一.HAProxy基础配置与应用实例: 1.快速安装HAProxy集群软件: HAProxy的官网: https://www.haproxy.org/#down下载HAProxy的源码包. 安装: [ ...

  8. Ubuntu 18.04使用sudo pip3报错

    在使用sudo pip3 install python库的时候出现如下警告: The directory '/home/lzhu/.cache/pip/http' or its parent dire ...

  9. vue中更换.ico图标报错路径找不到图片

    问题描述: vue项目中,想要更换.ico图片,更换完成后刷新页面报错,找不到路径. 解决: 更换完图片,重新启动下vue项目(npm run dev)就可以啦~ 哈哈哈 补充知识: 网页title旁 ...

  10. Bootstrap的插件

    04-Bootstrap的插件   1.下拉菜单 代码如下: <div class="dropdown"> <button class="btn btn ...