94
rated 0 times
[
99]
[
5]
/ answers: 1 / hits: 37295
/ 12 Years ago, wed, august 8, 2012, 12:00:00
I am trying to loop through all elements in a given div and output the results (C# code i will use later) to the screen for testing.
so if i have html like this:
<div id=testDiv>
<test>
<a>aVal</a>
<c>
<cc>ccVal</cc>
</c>
</test>
</div>
i am trying to produce this string value:
HtmlElement.CreateNode(test).AddNode(CreateNode(a).addText(aVal)).AddNode(CreateNode(c).AddNode(CreateNode(cc).addText(ccVal))
Right now i ahve this jquery in place, but i am unsure of how to drill down into the other nodes:
var x = HtmlElement.;
$('div#testDiv').children().each(function () {
var nodeNameStr = this.nodeName.toLowerCase();
var nodeText = $(this).text();
x += CreateNode(nodeNameStr).addText(nodeText)
});
More From » jquery