添加动态事件

===
<style>
.dn{background:red;color:white;text-decoration:underline;font-weight:bold}
.up{background:green;color:yellow;}
</style>
<p>aaaaaaaa</p>
<p>bbbbbbbb</p>
<p>cccccccc</p>
<p>ddddddddd</p>
<script>
o=document.all.tags("p");
for(i=0;i<o.length;i++){
o[i].onclick=function(){set(this)}
o[i].className='up';
}

function set(obj){
for(i=0;i<o.length;i++)
o[i].className='up';
obj.className='dn';
alert(obj.innerText);
}
</script>

 
posted @ 2006-12-26 10:44  attitudedecidesall  Views(103)  Comments(0Edit  收藏  举报