js与jquery语句调用方法

1、JS去掉首尾空格用法:

JQ:$.trim()方法

JS:function trimStr(str){return str.replace(/(^\s*)|(\s*$)/g,"");} var 变量=trimStr(需要去空格的字符串)

2、js创建一个div效果

openu:function(text){
     var menuid = 'reglot_opr';
     var menuObj = document.getElementById(menuid);
     menuObj = document.createElement('div');
     menuObj.id = menuid;
     menuObj.className = 'reglot_popmenu';
     document.body.appendChild(menuObj);
     var html='<div>'+text+'</div>';
     menuObj.innerHTML=html;
  }

 3、JS获取屏幕宽高、页面宽高(window.screen.availWidth)等

window.screen.availWidth 返回当前屏幕宽度(空白空间) 
window.screen.availHeight 返回当前屏幕高度(空白空间) 
window.screen.width 返回当前屏幕宽度(分辨率值) 
window.screen.height 返回当前屏幕高度(分辨率值) 
window.document.body.offsetHeight; 返回当前网页高度 
window.document.body.offsetWidth; 返回当前网页宽度

 

posted @ 2016-03-14 16:33  chenguiya  阅读(200)  评论(0)    收藏  举报