JavaScriptÖÐDOMÊ÷µÄNode½Ó¿ÚµÄһЩ¼òµ¥Ó¦ÓÃ
1. ÓÃÀàÃû²éÕÒÔªËØ
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN
" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
">
<html xmlns="http://www.w3.org/1999/xhtml
" >
<head>
<title>Untitled Page</title>
<script type="text/javascript
">
//±¾Ò³·½·¨:ÓÃÀàÃûÑ¡ÔñÔªËØ
function
getElements(cla) {
var
elements = document
.getElementsByTagName("*
");
var
elems = [];
for
(var
i = 0; i < elements.length
; i++) {
if
(elements[i].className && has(elements[i].className,cla)) {
elems.push(elements[i]);
}
}
return
elems;
}
function
has(ele, name
) {
var
clla = [];
if
(ele) clla = ele.split(' ');
for
(var
i = 0; i < clla.length
; i++)
if
(clla[i] == name
) {return
true
};
return
false
;
}
</script>
<style type="text/css
">
.h
{background-color:Aqua;
}
</style>
</head>
<body>
<i id="iiii
" class
="h
">Just test.</i><br />
<span id="ssss
" class
="h
">hehe</span>
<script type="text/javascript
">
var
e = getElements("h
");
var
nn = ""
for
(var
i = 0; i < e.length
; i++) {
nn +="id:
" + e[i].id + "\n
";
nn += "------line------\n
";
}
alert
(nn);
</script>
</body>
</html>
<
script
>
// This function takes a Node n, replaces it in the tree with an Element node
// that represents an HTML <
b
>
tag, and then makes the original node the
// child of the new <
b
>
Ïà¹ØÎĵµ£º
<script language="javascript">
function closeOpen(Panel) {
var test = document.getElementById('Panel');
if (test.style.display == "none") {
&nb ......
ÉÏÃæËù˵ÓйØHTMLµÄÄÚÈݷdz£ÉÙÓÖ¼òµ¥,µ«¶ÔÒѾÁ˽âµÄÈËÀ´Ëµ¾ÍÊÇûÓõÄ.
ÈçÓÐÎÊÌâ¿Éµ½È¨ÍþÍø http://www.html.com/ Éϲ鿴
ÒÔÏ¿ªÊ¼ËµËµ¹ØÓÚXMLµÄһЩ֪ʶ.
XMLÒ²ÊDZê¼ÇÓïÑÔ,¿ÉËüÊÇ×Ô¶¨ÒåµÄ,ûÓÐÒѸø¶¨¸ñʽ.²»¾ßÌå˵Ëü,¸ø³öÀý×ӾͿÉÃ÷ÁË.
Èç
<NAME>TOM</NAME>
<SEX>M</SEX>
ÒÔÉÏÄÚÈݵÄ< ......
ÀàÊÇʲô£¿
Ðí¶à¸Õ½Ó´¥±à³ÌµÄÅóÓѶ¼¿ÉÄÜÀí½â²»ÁËÀ࣬ÆäʵÀàÊǶÔÎÒÃÇÕâ¸öÏÖʵÊÀ½çµÄÄ£Ä⣬°ÑËü˵³É“Àà±ð”»òÕß“ÀàÐÍ”¿ÉÄÜ»á¸üÈÝÒ×Àí½âһЩ¡£±ÈÈç“ÈË”ÕâÖÖ¶¯
Îï¾ÍÊÇÒ»¸öÀ࣬¶ø¾ßÌåijһ¸öÈ˾ÍÊÇ“ÈË”Õâ¸öÀàµÄÒ»¸öʵÀý
£¬
“È ......
ÓÃjavascriptÏÔʾXML
Äã¿ÉÒÔÓÃJavaScriptÏÔʾXML¡£¿ÉÒÔÓÃJavaScript (»ò VBScript)´ÓÒ»¸öXMLÎļþÖÐÊäÈëÊý¾Ý²¢ÔÚÒ»¸öHTMLÒ³ÃæÄÚÏÔʾXMLÊý¾Ý¡£ Òª¿´¿´XMLºÍHTMLÊÇÈçºÎÏ໥²¹³äµÄ£¬¿ÉÒÔÕâÑù×ö£ºÊ×ÏÈÕÒµ½XML Îĵµ(note.xml)£¬È»ºó´ò¿ªHTMLÎĵµ
(note.htm)£¬Õâ¸öHTMLÎĵµÖаüº¬ÁËÔĶÁX ......
ÓÐʱºòÕÒµ½±ðÈËдµÄjs´úÂëÊÇѹËõ¹ýµÄ£¬Í¨¹ýÕâ¸ö¹¤¾ß¿ÉÒÔ¶Ô´úÂë½øÐиñʽ»¯¡£
<html>
<head>
<title>JS¸ñʽ»¯¹¤¾ß </title>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<mce:style><!--
* { padding:0px; margin:5px; font-size:13px; font-fami ......