coffee
9 years agoContributor
Finding Child and its property value in the DOM
Hi,
I have this piece of DOM
<tbody> <tr class="schedule 168045" data-timesheet-id="168045" id="Row00000"> <td class="hidden col-id-Num" data-col-id="Num" ... ... <tr class="schedule 168076 odd" data-timesheet-id="168076" id="Row00001"> <td class="active w100 col-id-EndTime" data-col-id="EndTime"> <div class="form001" data-form-element="FieldEdit"> <label for="">Finish</label> <input type="text" id="Schedule-01-Row1E-EndTime" class="nugget"> <input type="hidden" name="" id="Schedule-01-Row1E-EndTime" data-display-id="Row1E-Display" value="08:00" data-validate-method="time" class="validate"> <input type="text" class="ui" id="Row1E-EndTime-Display">
I am interested in the "Value="08:00"".
Any idea how can I get that "08:00" and save it in a variable ?
I tried the first step and TS returns error "TypeError Cannot read property 'length' of undefined".
Page = Sys.Browser('*').Page("www.myweb.com"); Parent_CSS = "#Table > div > table > tbody"; Parent = Page.QuerySelectorAll(Parent_CSS); var all_Children = Parent.children; Log.message(all_Children.length);
Basically, I wanted to find its parent by CSSSelector and then grab all its children.
Find out how many children its has. Go to the last Child and then grab its property (e.g. value = 08:00 or class = "validate")
Any suggestion how should I do that?
Thanks Heaps.
Try to iterate using:
...querySelector(CSS_selector).children.item(index). ... .textContent