1 2 3 4 5 6 下一页 本人在学习和做项目中常用的js函数汇总. 一、用js做的表格动态增删查改 工具JavaScript:util.js 1 2//全选反选 3function checkAll(boxName) { 4 var checkBox = document.getElementsByName(boxName); 5 for (i = 0; i < checkBox.length; i++) { 6 var checked = checkBox[i].checked; 7 if (checked) { 8 checkBox[i].checked = false; 9 } else { 10 checkBox[i].checked = true; 11 } 12 } 13} 14//多选验证 15function multiCheck(idArray) 16{ 17 //var idArray = document.getElementsByName(boxName); 18 var count = 0; 19 for(i=0;i<idArray.length;i++) 20 { 21 if(idArray[i].checked) 22 { 23 count++; 24 } 25 } 26 return count; 27} 28 29 30//回车切换焦点 31function toNext(next) 32{ 33 if(event.keyCode==13) 34 { 35 next.focus(); 36 } 37} 38 39//打开右键菜单 40function openShortCutMenu(oRow) 41{ 42 // 选中当前行 43 SelectRow(oRow); 44 aOpenPopMenu("ShortCutMenu"); 45 event.cancelBubble = true; 46 event.returnValue = false; 47} 48//关闭右键菜单 49function CloseShortCutMenu(){ 50 aClosePopMenu("ShortCutMenu"); 51} 52//显示右键菜单 53function aOpenPopMenu(MenuId){ 54 if (document.all(MenuId)){ 55 document.all(MenuId).style.left = event.clientX + document.body.scrollLeft; 56 document.all(MenuId).style.top = event.clientY + document.body.scrollTop; 57 document.all(MenuId).style.display = ""; 58 } 59} 60//隐藏右键菜单 61function aClosePopMenu(MenuId){ 62 if (document.all(MenuId)){ 63 document.all(MenuId).style.display = "none"; 64 } 65}
(责任编辑:admin) |