1.js操作select
添加item
var selectObj = document.getElementById('selectObj'); var varItem = new Option(text,value);//根据信息生成item selectObj.options.add(varItem);//将该item加入到select中
获取item的text值
function selectls(obj){ document.scl.llcontent.innerHTML = obj.options[obj.selectedIndex].text; }
/************************************************************/
2.js控制tr变色
function tochange(obj){ obj.style.backgroundColor ="#CCFFFF"; } function toreturn(obj){ obj.style.backgroundColor ="white"; } function tochange(obj){ obj.style.backgroundColor ="#CCFFFF"; } function toreturn(obj){ obj.style.backgroundColor ="white"; }
<tr οnmοuseοver="tochange(this);" οnmοuseοut="toreturn(this);"></tr>
屏蔽右键
document.οncοntextmenu=function(){//屏蔽右键 return false; }
/* 数字格式化 Javascript提供了对数字进行格式化输出的支持 Number对象提供的几种格式化函数: toExponential([fractionDigits]) :将数字按科学计数法格式返回,其中的fractionDigits值小数点后保留的位数。 toFixed([fractionDigits]) :将数字按指定的小数点位数返回,其中的fractionDigits值小数点后保留的位数。 toPrecision([precision]) :将数字按指定的精度返回(这个精度不是指小数点后几位),其中precision是指定的精度值。 */ var num=56.45678; var rs1=num.toExponential(2);//rs1的值为5.65e+1 var rs2=num.toFixed(2);//rs的值为56.45 var rs3=num.toPrecision(2);//rs的值为56