I have HTML like this:
<div data-suppattrtype="test1" class="testclass">
<p>
Hello Test1
</p>
</div>
<div data-suppattrtype="test2" class="testclass">
<p></p>
<div class="LotMoreContents">
<p>
First Time
</p>
<div id="Time">
<input type="text" id="start-time" value="123"/>
<input type="text" id="end-time" value="456"/>
</div>
<p>
Second Time
</p>
<div id="Time">
<input type="text" id="start-time" value="789"/>
<input type="text" id="end-time" value="012"/>
</div>
</div>
</div>
I am trying to extract the various start & end times which are present in the div test2. What I am trying to do is to get all the times and store it in a JSON object similiar to this:
[{"startTime": "123", "endTime": "456"}, {"startTime":"789", "endTime": "012"}]
To do this, I am able to get the innerHTML of test2 via this:
$( document ).ready(function () {
var $allDivs = $(this).find(".testclass");
$allDivs.each(function() {
var $suppAttrType = $(this).data('suppattrtype');
if($suppAttrType === "test2") {
/*Parse the the time objects within test2*/
}
});
});
I can access the HTML via $(this)[0] but I am unable to proceed further.
inputelements? If you change their ids to be unique you can just use$('input#first-start-time').val()to get the value.