verysu 设计模式 设计模式 响应式编程 百度开发平台 codeforces leetcode usfca

导航

jquery-javascript

$('#company_search').bind('keydown', function (event) {
if (event.keyCode == "13"){}
});
!相当于为null或为undefined
var reg=new RegExp(/[A-Za-z].*[0-9]|[0-9].*[A-Za-z]/);
$.trim(businessscope)
js跨域
1.window.addEventListener("message", function( event ) {    
        });
window.frames[0].postMessage(post,'http://127.0.0.1:8080');
2.
if(typeof(exec_obj)=='undefined'){
exec_obj = document.createElement('iframe');
exec_obj.name = 'tmp_frame';
exec_obj.src = 'http://${oaHostName}/oa/indexRefresh.html';
exec_obj.style.display = 'none';
document.body.appendChild(exec_obj);
}else{
exec_obj.src = 'http://${oaHostName}/oa/indexRefresh.html?' + Math.random();
}
$(document).stk_removeSelf(true);
iframe.contentWindow.location.href='${param.page}'
IE获取焦点 跨域可用select()
patrn =/^(([1-9]{1}\d*)|(0{1}))(\.\d{0,2})?$/;
/^[1]([3-9])[0-9]{9}$/;// 验证手机号
/^[1-9]{1}[0-9]{5,8}$/;// 验证没有区号的
/^[0][1-9]{2,3}-[0-9]{5,10}$/;// 验证带区号的
/^(\w)+(\.\w+)*@(\w)+((\.\w+)+)$/;//email
java中传js参数\""+entityName+"\"
看html选人控件不会重新生成代码,所以会在第二个弹窗代码之上,如果放到下面就没问题,那代码这里就把选人控件的代码在showunit之前重新append到最后面去 $('body').append($('#org_unit_wrap').parent().parent().parent().parent())
$('body').append($('#org_unit_wrap').parent().parent().parent().parent())
关闭指定页面
window.parent.opener.location=<%="http://192.168.3.174:8080/firstlink.jsp"%>;
window.close();
谷歌非自己js打开的窗口关闭方式
window.opener = null;
window.location.href="about:blank";
window.opener = null;
window.open(" ","_self");
window.parent.close();
172.16.200.253:9999/test_war/index.jsp
window.parent.close();
jsonp请求方式
demo.js[{"name":"何开","sex":"女","email":"demo3@123.com"}]
$.getJSON("demo.js", function(json) {alert(JSON.stringify(json));});
jQuery.parseJSON(var)
对类型定义一个原型
Array.prototype.in_array = function (element) {}用法arr.in_array(var)
扩展方法使用 if($.fn.prop==null)再创建
jQuery.extend({
function a(){}
}
命名空间扩展
jQuery.myPlugin = {
a:function a(){}
}
(function ($) {
    var ops = $.extend({},dft,options);//jQuery.extend() 函数用于将一个或多个对象的内容合并到目标对        象。这里其实是让实例化中的对象合并到目标对象里
    $.fn.extend({
        var self=this;//这里的this 就是 jQuery对象
        sel=$(this); //获取当前dom 的 jQuery对象
        fa:function(){}
    });
}(jQuery);
添加静态方法
jQuery.jFN = function () {} jQuery是对象
添加dom实例方法
jQuery.fn.fnDOM = function () {}
全局变量
window.test;window['a']
关闭ajax缓存
$.ajax ({
            cache: false  //关闭AJAX相应的缓存
        });
设置ajax同步
$.ajaxSetup({
type: "POST",
async: false,
cache: false,
dataType: "JSON",
error: function (jqXHR, textStatus, errorThrown) {
switch (jqXHR.status) {
case(1):
alert("请求超时");
break;
default:
alert("未知错误");
}}});
设置html组件的属性
$("#startdate").css("width","160px");
$(this).prop("title",_text);
element.style.display="inline-block";
$('#checker').find("span")[0].setAttribute("allowblank",true);
$("#checker").removeAttr("onchange");
$("#downloadNewsAttach").unbind();
$("#downloadNewsAttach").on('click',function(){});
$('input[name="'+checkName+'"]:checked').length
$("#tg_list_1_fix1").fadeOut(1000,function(){$(this).show();});
$("#tg_list_1_fix1").fadeIn(1000,function(){$(this).show();});
$("#xs_10_5isfenduan").fadeIn(200);
$("#xs_10_5isfenduan").fadeTo(200,0.5[不透明度],function(){});
//获取窗口的滚动条的垂直位置
$(window).scrollTop()
$('html,body').animate({scrollTop:$($.attr(this, 'href')).offset().top}, 800);
$('html,body').animate({scrollTop:$("#rg_1_1_productFeeForm").offset().top}, 800);
$('html,body').animate({scrollTop:$("#rg_1_1_productFeeForm").offset().top},{duration: 500,easing: "swing"});
$('elem').animate({width:"1px",height:"5px"}1500,function(){});
 
.addClass("layui-this").siblings("li").removeClass("layui-this");
document.querySelectorAll('form').forEach(function(el){});
document.getElementById("rg_1_1_productFeeForm").scrollIntoView(true);
obj.parentNode.removeChild(obj);
document.getElementById("").style.top='1px';
$("#__alertDiv").css({'top':'1px'});
$("#anothertable").find("tr").each(function (i, e) {}
$("#remark").bind('paste', function (e) {setTimeout(function () {}, 100);});
$("#id").find("div[name='name']")
"input[type='type'][name='name']"
"input[type='radio']:checked"
获取对应id下的索引列索引行$('#basicmemoTable_HT tr:eq(0) th:eq(0)')
滑动方式隐藏/显示$("p").slideUp();.slideDown();.slideToggle();.slideDown(150,function(){//操作});
清空$("#id").empty();
颠倒数组中元素的顺序array.reverse();
查找指定条件子元素.children("div[name='childDiv']")
$('label[for="sdaasdd"]')
$("[href$='.jpg']")
"tr[type] > th[collect]"
允许脚本连接任何服务器并且交互数据的安全,可信XDomainRequest
启用禁用滚动document.documentElement.style.overflow = 'hidden';
document.documentElement.style.overflowY = 'scroll';
document.documentElement.clientHeight/document.body.clientHeight
 
 
/*
//worker1
var txt = document.getElementById("basicInforemark");
var worker1 = new Worker("/plm/js/thread1.js");
document.getElementById("saveb1").addEventListener("click",function(){
var postData = txt.value;
worker1.postMessage(postData);
},false);
worker1.onmessage=function(e){
console.log(e);
worker1.terminate(); //主线程主动关闭辅助线程worker (辞退后不在接收辅助线程的消息)
this.close();
}*/
 
/*
//worker2
var worker = new SharedWorker('/plm/js/thread1.js');
var txt = document.getElementById("basicInforemark");
worker.port.onmessage = function(e) { // note: not worker.onmessage!
debugger;
txt.value = '\n' + e.data;
}*/
 
//worker3
/*var txt = document.getElementById("basicInforemark");
var worker2 = new SharedWorker('/plm/js/thread1.js');
worker2.port.addEventListener('message', function(e) {
debugger;
txt.value = '\n' + e.data;
}, false);
worker2.port.start(); // note: need this when using addEventListener
worker2.port.postMessage('ping');*/
//work4
var worker = new SharedWorker('/plm/js/thread1.js');
var get = document.getElementById('basicInforemark');
var set = document.getElementById('saveb1');
var txt = document.getElementById('basicInforemark');
worker.port.addEventListener('message', function(e) {
debugger; var a = e.data;
}, false);
worker.port.start(); // note: need this when using addEventListener
set.addEventListener('click',function(e){
worker.port.postMessage(txt.value);
},false);
get.addEventListener('click',function(e){
worker.port.postMessage('get');
},false);
//thread1.js
//importScripts('script2.js', 'selectworkplan.js');//并且可以同时加载多个脚本
/*
//onconnect1
onmessage = function(event){
debugger;
var res = event.data+",你很帅气!";
postMessage(res);
}*/
 
/*//onconnect2
onconnect = function(e) {debugger;
var port = e.ports[0];
port.postMessage('Hello World!');
}*/
/*//onconnect3
onconnect = function(e) {debugger;
var port = e.ports[0];
port.postMessage('Hello World!');
port.onmessage = function(e) {
debugger;
port.postMessage('pong'); // not e.ports[0].postMessage!
// e.target.postMessage('pong'); would work also
}
}*/
//onconnect4
onconnect = function(e) {
debugger;
var port = e.ports[0];
port.onmessage = function(e) {debugger;
if(e.data=='get'){
port.postMessage(data);
}else{
data=e.data;
}}}
//父窗口代码 2 <iframe src="./winPostMessage.html"></iframe>
<script>
window.onmessage = function(e){
console.log(e);
console.log(e.data.name);//他乡踏雪 7 }
</script>
$(".tip").css({"top":e.pageY+"px","left":e.pageX+"px"}).show(1000);
//子窗口代码11 <script>
window.parent.postMessage({name:"他乡踏雪"},'http://localhost/')
</script>
查找以什么开头/结束/包含的所有id$('[id^="basicInfocode"]'); $('[id$="basicInfocode"]');$('[id*="basicInfocode"]');
标题属性包含单词"flower"的所有元素[title~=flower]
选择p元素之后的每一个ul元素p~ul    选择每个p元素的是其父级的第二个子元素,从最后一个子项计数p:nth-last-child(2)
当在html中清除内置缓存组件清除不掉时,时使用
dom.parentElement.parentElement.parentElement.remove();即可清除
 
 数组遍历

"sdsd".split('').forEach(function(e){});
Array.prototype.forEach.call("sdsd".split(''),function(e){alert(e)});
for(j in "sdsd".split('')) {alert(j)};//只能获得索引
"sdsd".split('').map(function(n){alert(n);});
for(let value of "sdsd".split('')) {alert(value);}

 
 
 
 
 
 

posted on 2020-01-07 19:33  泳之  阅读(122)  评论(0编辑  收藏  举报

我是谁? 回答错误