// jQuery
$(window).load(function(){
// 代码1
});
// JavaScript
window.onload = function(){
// 代码2
};
function one(){
alert('1');
}
function two(){
alert('2');
}
// JavaScript
window.onload = one;
window.onload = two;//只执行two()
// jQuery
$(document).ready(function(){
one();
});
$(document).ready(function(){
two();
});//one() 和 two()都会执行
<div id="div1"></div>
<div id="div2"></div>
<script type="text/javascript">
$(function(){
$('#div1').bind('click',function(){
$(this).next().show();
});
});
$(function(){
$('#div1').bind('click',function(){
if($(this).next().is(':visible')){
$(this).next().hide();
}else{
$(this).next().show();
}
});
});
$('#div1').click(function(){
if($(this).next().is(':visible')){
$(this).next().hide();
}else{
$(this).next().show();
}
})
$('#div1').hover(function(){
$(this).next().show();
},function(){
$(this).next().hide();
});
$('#div1').toggle(function(){
$(this).next().show();
},function(){
$(this).next().hide();
});
$('#div1').click(function(ev){
alert(ev.type);//click
})
$('#div1').click(function(ev){
alert(ev.target.id);//div1
})
$('#div1').click(function(ev){
alert(ev.pageX + ',' + ev.pageY);//275,181
})
$('#div1').click(function(ev){
alert(ev.which);//1是鼠标左键,2是鼠标中见,3是鼠标右键
})
$('#div1').bind('click',function(){
alert('1');
}).bind('click',function(){
alert('2');
}).bind('mouseover',function(){
alert('3');
})
$('#btn').bind('myclick',function(){
alert('1');
});
$('#btn').trigger('myclick');
$('#btn').bind('myclick',function(event,message1,message2){
alert(message1 + message2);
});
$('#btn').trigger('myclick',["1","2"]);
$('div').bind('click.plugin',function(){
alert('1');
});
$('div').bind('mouseover.plugin',function(){
alert('2');
});
$('div').bind('dbclick.plugin',function(){
alert('3');
});
$('button').click(function(){
$('div').unbind('.plugin');
})
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有