js - script标签的for属性和event属性

js - script标签的for属性和event属性

<script language="javascript" for="window" event="onload">

alert("hello word!");

</script>

// for 属性指定脚本执行对象(给谁用的)

// event 属性指定脚本执行事件(在什么时候执行)



// 上面的代码相当于:

$(document).ready(function(){alert("hello word!");}

注:只有IE支持这种语法

posted @ 2022-09-07 16:20  zc-lee  阅读(391)  评论(0编辑  收藏  举报