js自动触发事件&&自定义事件

JavaScript023

js自动触发事件&&自定义事件,第1张

eventType共有5种类型:

上述加粗的是经常会用到的事件类型

以 eventType=MouseEvents ,触发事件为 click 为例:

改成下面的试试

<script type="text/javascript">

$(document).ready(function()

{

$(".header").animate({ width: 'hide', display: 'none' })

$("ul.menu").animate({ width: 'show' ,height:'show' ,display:'block',}) 

$(".header").animate({ width: 'show', display: 'block' })

$("ul.menu").animate({ width: 'hide' ,height:'hide',display:'none',}) 

})

</script>

普通的直接写就可以了,如有一个函数定义function hello()要调用直接hello():

延迟触发:

setTimeout(方法,秒数);如setTimeout("hello()",1000)代表一秒后执行一次hello方法

setinterval(方法,秒数);如setinterval("hello()",1000)代表每间隔一秒执行一次hello方法