常见的js函数
{
if(num<10)
{
return "0"+num;
}
else
{
return ""+num;
}
}
{
switch(day)
{
case 0: return ‘周日‘;
case 1: return ‘周一‘;
case 2: return ‘周二‘;
case 3: return ‘周三‘;
case 4: return ‘周四‘;
case 5: return ‘周五‘;
case 6: return ‘周六‘;
}
}
function $(vArg){if(typeof vArg == ‘function‘)
{window.onload = vArg;}else if(typeof vArg == ‘string‘){return document.getElementById(vArg);}else if(typeof vArg == ‘object‘){return vArg;}}$(function(){$(‘div1‘).onclick = function(){$(this).style.background = ‘red‘;};})
$(‘#div1‘).click(function(){
$(this).css(‘background‘,‘red‘);
})
})*/
if(num1<num2)
{
return -1; //第一个比第二个靠左
}
else if(num1>num2) //右
{
return 1;
}
else //一样
{
return 0 ;
}
});
alert(arr);
return num1-num2;
});
alert(arr);
arr.sort(function(str1,str2){
return str1.localeCompare(str2);
});
alert(arr);
alert(‘a‘);
}
return ‘就不让你弹出来‘;
}
{
var i =0;
for(i=0;i<arr.length;i++)
{
if(arr[i]==num)
{
}
return false;
}
{
oBtn.attachEvent(‘onclick‘,aaa);
oBtn.attachEvent(‘onclick‘,bbb);
}
else
{
oBtn.addEventListener(‘click‘,aaa,false);
oBtn.addEventListener(‘click‘,bbb,false);
}
function myAddEvent(obj,sEvent,fn) //绑定事件
{
if(obj.attachEvent)
{
obj.attachEvent(‘on‘+ sEvent,fn);
}
else
{
obj.addEventListener(sEvent,fn,false);
}
}
myAddEvent(oBtn,‘click‘,bbb);
<span>SPAN</span>
<p>P</p>
div{ background:#0000FF;width:100px;height:100px;}
span{ background:#00FF00;width:100px;height:100px;}p{ background:#FF0000;width:100px;height:100px;}
var oTable = document.getElementById(‘tb‘);
for(var i=0; i<oTable.rows.length; i++)
{
if(i%2==0)
{
oTable.rows[i].onmouseover = function()
{
this.style.backgroundColor = ‘#ffff66‘;
}
oTable.rows[i].onmouseout = function()
{
this.style.backgroundColor = ‘#d4e3e5‘;
}
}
}
}
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。