Tag: TR onclick TD onclick event binding
<table id= "TB" ><tr><td>1111111</td><td>1111111</td><td>1111111</td ><td>1111111</td><td>1111111</td><td>1111111</td></tr></table ></body> <script type= "Text/javascript" >var td = document.getElementById ("TB"). getElementsByTagName ("tr") [0].getelementsbytagname ("TD") for (var i = 0; i < td.length; i + +) { Td[i].onclick = func tion () {Alert ("x")}}for (var i = 0; i < td.length; i + +) { if (i = = 0 | | I ==td.length-1) Td[i].onclick = null}
</script>
IE event.stoppropagation () block bubbling events
in Firefox Firefox , opera, ie block bubble event is different code, Firefox use is event.stoppropagation (), and IE under the use of cancelbubble , JQuery can be compatible with e.stoppropagation (), and if it is purely JavaScript requires the following code to unify:
if (event.stoppropagation) {//This code was for Mozilla and Opera event.stoppropagation ();} else if (window.event) {// This code was for IE window.event.cancelBubble = true; }
TR bound onclick event, how to exclude some of these TD bindings to the onclick event