惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

云风的 BLOG
云风的 BLOG
M
MIT News - Artificial intelligence
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
V2EX - 技术
V2EX - 技术
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
GbyAI
GbyAI
aimingoo的专栏
aimingoo的专栏
腾讯CDC
C
CERT Recently Published Vulnerability Notes
J
Java Code Geeks
WordPress大学
WordPress大学
博客园 - Franky
V
Vulnerabilities – Threatpost
小众软件
小众软件
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
有赞技术团队
有赞技术团队
The Hacker News
The Hacker News
T
The Blog of Author Tim Ferriss
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Martin Fowler
Martin Fowler
Webroot Blog
Webroot Blog
Attack and Defense Labs
Attack and Defense Labs
Google Online Security Blog
Google Online Security Blog
S
Securelist
Security Archives - TechRepublic
Security Archives - TechRepublic
T
Troy Hunt's Blog
Scott Helme
Scott Helme
Project Zero
Project Zero
T
Tailwind CSS Blog
The Register - Security
The Register - Security
A
About on SuperTechFans
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
The GitHub Blog
The GitHub Blog
Security Latest
Security Latest
L
LangChain Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
H
Hackread – Cybersecurity News, Data Breaches, AI and More
大猫的无限游戏
大猫的无限游戏
Cloudbric
Cloudbric
S
Security Affairs
博客园 - 叶小钗
Microsoft Security Blog
Microsoft Security Blog
H
Heimdal Security Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
PCI Perspectives
PCI Perspectives
The Cloudflare Blog
Last Week in AI
Last Week in AI
阮一峰的网络日志
阮一峰的网络日志
AI
AI

博客园 - hemingchen

MiniProfiler asp.net MVC控制器中返回JSON格式的数据时提示下载 Delphi XE2 新技术说明 (What's new in Delphi XE2)(转载) Microsoft.VisualStudio.Xaml 加载错误 解决 网页如何有效调用exe Response.ContentType 详细列表 - hemingchen - 博客园 SQL 2005 开启OpenRowset/OpenDatasource的办法 常用正则表达式 - hemingchen - 博客园 XMLHTTP 保护自己的眼睛 转载 37个Ajax和CSS实现的Tab选项卡切换效果界面 SQL2005附加数据库"失败........无法更新数据库"xxx",因为数据库是只读 - hemingchen - 博客园 asp.net C# 下母版页使用 .net Access 新增记录后获取自动编号的值 JavaScript 脚本文件编码导致的问题 jquery json简单例子 jquery ajax xml jquery学习 使用面向对象的技术创建高级 Web 应用程序 文章来源:http://msdn.microsoft.com/zh-cn/magazine/cc163419.aspx本文讨论:
js parentElement - hemingchen - 博客园
hemingchen · 2009-02-13 · via 博客园 - hemingchen

<a href="http://sighttp.qq.com/cgi-bin/check?sigkey=a495e8ecdb9706da396929cf00ab6994683579aeb480e95867f7b027880b6b257ff6c38e3045a766df65e31bee05acefa20b053ae86d798501cb768fb02c84e8"; target=_blank; onclick="var tempSrc='http://sighttp.qq.com/wpa.js?rantime='+Math.random()+'&sigkey=a495e8ecdb9706da396929cf00ab6994683579aeb480e95867f7b027880b6b257ff6c38e3045a766df65e31bee05acefa20b053ae86d798501cb768fb02c84e8';var oldscript=document.getElementById('testJs');var newscript=document.createElement('script');newscript.setAttribute('type','text/javascript'); newscript.setAttribute('id', 'testJs');newscript.setAttribute('src',tempSrc);if(oldscript == null){document.body.appendChild(newscript);}else{oldscript.parentNode.replaceChild(newscript, oldscript);}return false;"><img border="0" SRC='http://wpslogo.qq.com/qq_online.gif'  alt="点击这里给我发消息"></a> &nbsp;&nbsp;(点击及可直接咨询)

<html>
<head> </head>
<body>
<form       name= "a ">      
<table   name= "b ">      
<tr   name= "c "   >      
                                <td   name= "d "   >      
                                            <select     name= "e "     onchange= "xx(this.parentElement.parentElement.parentElement.name) ">
    <option   > 1 </option>
    <option   > 2 </option>
    <option   > 3 </option>
    <option   > 4 </option>

    </select>
                                </td>    
<td> &nbsp; </td>
                                 
                    </tr>      
    <tr> &nbsp; </tr>
            </table>      
    </form>  
  </body>
  <script   language= "javascript ">
  function   xx(a)
  {
      alert(a);
  }
  </script>
</html>
//输出undefined   为什么了?   不是应该输出b么?

改成 this.parentElement.parentElement.parentElement.parentElement.name    正确输出
其实代码应该这样理解
<table>
<tbody>
<tr>
<td>
</td>
</tr>
有如:
   <SCRIPT language="javascript">
         function showHide(obj){
          var oStyle = obj.parentElement.parentElement.parentElement.rows[1].style;
         // obj.parentElement.parentElement.parentElement.rows[1].这里获取的是TABLE 第二行 id为sub的单元行
          oStyle.display == "none" ? oStyle.display = "block" : oStyle.display = "none";
         }
   </SCRIPT>

 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
 </HEAD>
 <BODY bgColor="#9aadcd" leftMargin="0" topMargin="0" >
  <br>
<asp:Repeater ID="LeftMenu" runat="server" OnItemDataBound="LeftMenu_ItemDataBound" >
  <ItemTemplate>
        <TABLE cellSpacing="0" cellPadding="0" width="159" align="center" border="0" >
          <TR >
           <TD width="23"><IMG height="25" src="images/Menu/box_topleft.gif" width="23"></TD>
           <TD class="ttl"
            onclick="JavaScript:showHide(this);" width="129" background="images/Menu/box_topbg.gif"><%# Eval("M_CName")%></TD>
           <TD width="7"><IMG height="25" src="images/Menu/box_topright.gif" width="7"></TD>
          </TR>
          <TR style="DISPLAY: none" id="sub">
           <TD background='images/Menu/box_bg.gif' colSpan='3'>
            

             <TABLE width='100%'>
                 <TBODY>
                 <asp:Repeater ID="LeftMenu_Sub" Runat="server" >
                 <ItemTemplate>
               <TR>
               <TD><IMG height='7' hspace='5' src='images/Menu/arrow.gif' width='5' align='absMiddle'>
                <asp:HyperLink ID ="Hyperlink1" Runat ="server" Target ="mainFrame" NavigateUrl='<%# Eval("M_Directory")%>'>
                 <%# Eval("M_CName")%>
                </asp:HyperLink>
               </TD>
              </TR>
              </ItemTemplate>
              </asp:Repeater>
                          </TBODY>
                         </TABLE>

                    </TD>
               </TR>
            <TR>
            <TD colSpan="3"><IMG height='10' src='images/Menu/box_bottom.gif' width='159'></TD>
            </TR>
         </TABLE>
        </ItemTemplate>
</asp:Repeater>  
 </BODY>
</html>