Results 1 to 2 of 2

Thread: How do I find an element by className?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2010
    Posts
    16

    How do I find an element by className?

    How would I find a part of a document by class name?
    Like heres the code of what I cam trying to find:

    Code:
    <td style="padding-left:2px;"><div class="t_verde" style="font-size:12px;padding-top:1px;padding-bottom:1px;">4</div> </td>
    What I want to do is find this item within the document by it's classname:

    class="t_verde"

    I know how to get things by Id:

    Code:
    Dim find As HtmlElement = Me.Browser.Document.GetElementById("t_verde")
    But how would I find by classname?

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: How do I find an element by className?

    vb Code:
    1. for each element as htmlelement in Me.Browser.Document.getelementsbytagname("div")
    2.     if element.getattribute("className") = "t_verde" then
    3.         'found it
    4.     end if
    5. next

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width