parent和next的用法

2015-03-02 13:48:26  访问(1369) 赞(0) 踩(0)

  • 
    <!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> 
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
    <title>parents的用法</title> 
    <script type="text/javascript" src="<%=jQuery%>"></script> 
    <script type="text/javascript"> 
    $(document).ready(function() {
    $("#btn1").click(function(){
    alert($(this).parent().next().html());
    //this.parent()是input前面的td
    ////this.parent().parent()获取的是tr
    //////this.parent().parent().parent()获取的是table
    ////////this.parent().next()获取的是td相临的td
    });
    });
    </script> 
    
    <%=VersionHideInfo%>
    
    </head> 
    <body> 
    
    <table>
    <tr>
          <td><input id="btn1"  class="btn" type="button"  value="test"/></td>
          <td>some text</td>
    </tr>
    </table>
    </body> 
    </html> 
    


上一条:

下一条:


 

相关评论

评论加载中……
 

发表评论

类型:
内容:
  (Alt+Enter)