javascript eventʼþ½âÎö1 only handbook
event.srcElement Óëevent.target
Javascript event.srcElement
¸Ð¾õÕâ¸öͦºÃ£¬¿ÉÒÔ²¶»ñµ±Ç°Ê¼þ×÷ÓõĶÔÏó£¬Èçevent.srcElement.tagName¿ÉÒÔ²¶»ñ»î¶¯±ê¼ÇÃû³Æ¡£
×¢Òâ»ñÈ¡µÄ±ê¼Ç¶¼ÒÔ´óд±íʾ£¬Èç"TD","TR","A"µÈ¡£ËùÒÔ°Ñ¿´¹ýµÄһЩ³ÏÂÀ´£¬²»¼ÇµÃµÄʱºòÔÙÀ´¿´¿´¡£
<script type="text/javascript">
function tdclick(){
if(event.srcElement.tagName.toLowerCase()=='td')
alert("ÐУº"+(event.srcElement.parentNode.rowIndex+1)+"ÁУº"+(event.srcElement.cellIndex+1));
}
</script>
event.srcElement´Ó×ÖÃæÉÏ¿ÉÒÔ¿´³öÀ´ÓÐÒÔϹؼü×Ö£ºÊ¼þ,Ô´ ËûµÄÒâ˼¾ÍÊÇ£ºµ±Ç°Ê¼þµÄÔ´£¬
ÎÒÃÇ¿ÉÒÔµ÷ÓÃËûµÄ¸÷ÖÖÊôÐÔ ¾ÍÏñ:document.getElementById("")ÕâÑùµÄ¹¦ÄÜ£¬
¾³£ÓÐÈËÎÊ firefox Ï嵀 event.srcElement ÔõôÓã¬ÔÚ´ËÏêϸ˵Ã÷£º
IEÏÂ,event¶ÔÏóÓÐsrcElementÊôÐÔ,µ«ÊÇûÓÐtargetÊôÐÔ;FirefoxÏÂ,event¶ÔÏóÓÐtargetÊôÐÔ,µ«ÊÇûÓÐsrcElementÊôÐÔ.µ«ËûÃǵÄ×÷ÓÃÊÇÏ൱µÄ£¬¼´£º
firefox Ï嵀 event.target = IE Ï嵀 event.srcElement
½â¾ö·½·¨:ʹÓÃobj(obj = event.srcElement ? event.srcElement : event.target;)À´´úÌæIEϵÄevent.srcElement»òÕßFirefoxϵÄevent.target.
ת×Ô£ºhttp://www.cnblogs.com/Robin-wu/archive/2008/07/25/1251453.html
Ïà¹ØÎĵµ£º
DOM
Document Object Model
ÊDZí´ïʽXMLÎĵµµÄ³£¼û·½Ê½£¬DOM¸ø¿ª·¢ÕßÌṩÁËÒ»ÖÖ¶¨Î»XML²ã¼¶½á¹¹µÄÖ±¹Û·½·¨¡£
½âÎö²¢ä¯ÀÀDOMÎĵµµÄÓÐЧ·½·¨ÎÞÒÉÄܼò»¯JavaScriptµÄ¿ª·¢¡£
¹é¸ù½áµ×£¬JavaScriptÖоø´ó²Ù×÷¶¼ÊÇJavaScriptºÍÍøÒ³ÀﲻͬµÄHTMLÔªËØÖ®¼äµÄ½»»¥£¬¶øDOMÔòÊǼò»¯ÕâÒ»¹ý³ÌµÄ³öÉ«¹¤¾ß¡£
ÀýÈ磺
» ......
ÍøÒ³¿É¼ûÇøÓò¿í£ºdocument.body.clientWidth
ÍøÒ³¿É¼ûÇøÓò¸ß£ºdocument.body.clientHeight
ÍøÒ³¿É¼ûÇøÓò¿í£ºdocument.body.offsetWidth(°üÀ¨±ßÏߵĿí)
ÍøÒ³¿É¼ûÇøÓò¸ß£ºdocument.body.offsetHeight(°üÀ¨±ßÏߵĿí)
ÍøÒ³ÕýÎÄÈ«ÎÄ¿í£ºdocument.body.scrollWidth
ÍøÒ³ÕýÎÄÈ«Îĸߣºdocument.body.scrollHeight
ÍøÒ³±»¾íÈ¥µ ......
Ò»Ö±Ïë¶ÔJavascriptÔÙ´Î×öһЩ×ܽᣬÕýºÃ×î½ü×Ô¼ºÐ´ÁËÒ»¸öСÐÍJs
UI¿â£¬×ܽáÁËÒ»ÏÂJsµÄ¼Ì³Ð»úÖÆ£¬ÔÚÍøÉÏÒ²¿´ÁËһЩǰ±²ÃDz©¿ÍÀïµÄ×ܽᣬ¸Ð¾õ·ÖÎö²»ÊÇÌØ±ðÈ«Ãæ¡£ÕâÀï½ö½öÊǰÑ×Ô¼ºµÄѧϰÌå»áÄóöÀ´·ÖÏíһϣ¬Ï£Íû¶Ô´ó¼Ò
ѧϰJavascriptÓÐËù°ïÖú¡£
Javascript±¾ÉíÊÇ´ÓPerlÓïÑÔµÄÓï·¨ÑÝ±ä¶øÀ´µÄ£¬±¾ÖÊÉÏÊǽű¾ÓïÑÔ ......
ÄãÖªµÀÊÀ½çÉÏÓжàÉÙÖÖä¯ÀÀÆ÷Â𣿳ýÁËÎÒÃÇÊìÖªµÄIE, Firefox, Opera, SafariËÄ´óä¯ÀÀÆ÷Ö®Í⣬ÊÀ½çÉÏ»¹Óнü°ÙÖÖä¯ÀÀÆ÷¡£
¼¸Ììǰ£¬ä¯ÀÀÆ÷¼Ò×åÓиյ®ÉúÁËһλСÍõ×Ó£¬¾ÍÊÇGoogleÍÆ³öµÄChromeä¯ÀÀÆ÷¡£ÓÉÓÚChrome³öÉúÃûÃÅ£¬¾¡¹ÜËû»¹ÊǸöС¼Ò»ï£¬Ã»ÓÐÈ˸ÒС¿´Ëû¡£ÒÔºó£¬ÔÛÃdz£Ëµä¯ÀÀÆ÷µÄ&ld ......
javascript»ñÈ¡selectµÄֵȫ½â
»ñÈ¡ÏÔʾµÄºº×Ö
document.getElementById("bigclass").options[window.document.getElementById("bigclass").selectedIndex].text
»ñÈ¡Êý¾Ý¿âÖеÄid
window.document.getElementById("bigclass").value
»ñÈ¡select×é·ÖÅäµÄË÷Òýid
window.document.getElementById("bigclass").selected ......