zoukankan      html  css  js  c++  java
  • C#中的GetElementsByClassName方法


    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
        public static class Spread
        {
            /// <summary>
            /// 检索指定class的所有HtmlDocument对象
            /// </summary>
            /// <param name="doc"></param>
            /// <param name="className"></param>
            /// <returns></returns>
            public static HtmlElement GetElementsByClassName(this HtmlDocument doc, string className)
            {
                HtmlElementCollection collection = doc.All;
                //HtmlElementCollection collection = doc.Body.All;
                HtmlElement html = doc.CreateElement("");
     
                foreach (HtmlElement he in collection)
                {
                    if (he.GetAttribute("classname") == className)
                    {
                        html.AppendChild(he);
                    }
                }
                return html;
           
  • 相关阅读:
    使用git管理github项目
    router 跳转页面
    JS中[object object]怎么取值
    微信授权获取code
    闭包
    css属性clear
    javaScript循环
    css属性position
    跨域
    浅析JS内存 一
  • 原文地址:https://www.cnblogs.com/c-x-a/p/6943338.html
Copyright © 2011-2022 走看看