zoukankan      html  css  js  c++  java
  • getElementById

    getElementById:
    
    node2:/var/www/html/aa#cat a7.html 
    <html>
    <body>
    <div id='ID'>科技</div>
    <script type="text/javascript" src="jquery-2.2.2.min.js"></script>
    <script type="text/javascript" src="a7.js"></script>
    </body>
    </html>
    node2:/var/www/html/aa#cat a7.js
    var domObj = document.getElementById("ID");//获得DOM对象
    console.log(domObj);
    var ObjHTML= domObj.innerHTML;
    console.log(ObjHTML);
    
    Navigated to http://192.168.137.3/aa/a7.html
    <div id="ID">
    a7.js:2:1
    科技
    
    根据ID获取值:
    
    [root@node01 tmp]# cat a1.html 
    <html>
    <body>
    <div id='ID'>科技1</div>
    <div id='ID'>科技2</div>
    <script type="text/javascript" src="jquery-2.2.2.min.js"></script>
    <script type="text/javascript" src="a7.js"></script>
    </body>
    </html>
    [root@node01 tmp]# cat a1.pl
    use LWP::UserAgent;    
    use POSIX;    
    use HTML::TreeBuilder::XPath;     
    use Encode;     
    use HTML::TreeBuilder;      
    use HTML::TreeBuilder::XPath;    
    use DBI;    
    use Encode;  
        my $tree= HTML::TreeBuilder::XPath->new;    
           $tree->parse_file("a1.html");  
             my @pageString = $tree->findvalues('//html/body/div[@id="ID"]');    
           print "@pageString is @pageString
    ";   
    [root@node01 tmp]# perl a1.pl
    @pageString is 科技1 科技2
    [root@node01 tmp]# 

  • 相关阅读:
    Redis常见数据类型
    MYSQL常见可优化场景
    算术切片
    找数组里没出现的数
    不同路径和(II)
    不同路径和
    最小路径和
    强盗抢房子
    丑数(2)
    判断子序列
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349303.html
Copyright © 2011-2022 走看看