Accroding to your description,as far as I think,the div of buyer_credit_information is a child of the div of Sales.So,you could each the div of Sales to find the div of buyer_credit_information .Also,I suggest you could use child selector (>) for select
the child.This will select all children of divs using the context of #Sales.
More details,you could refer to below codes:
<script src="Scripts/jquery-3.4.1.min.js"></script>
<script>
$(function () {
$("#Button1").click(function () {
var x = $("div > div > div", "#Sales").text();
alert(x);
})
})
</script>
<asp:Button ID="Button1" runat="server" Text="Button" />
<div id="Sales" style="display:none">
<div id="SalesType">-- static content (new, used)</div>
<div id="Application">
<div class="BuyerInformation">
<div class="buyer_credit_information">
-- content need to output to file
</div>
</div>
</div>
</div>
Result:
Best regards,
Yijing Sun
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Member
2 Points
30 Posts
get content in div tags
Mar 24, 2020 02:29 PM|GeorgeTheCoder|LINK
I have a web page that I have to get the content from div tags, however, I'm running into issues when using
it's not finding the div.
My div structure:
I need the content from the buyer_credit_information DIV tag.
All-Star
58174 Points
15650 Posts
Re: get content in div tags
Mar 24, 2020 05:28 PM|bruce (sqlwork.com)|LINK
nextAll() returns siblings, not nested, and which dom element does this point to?
Member
2 Points
30 Posts
Re: get content in div tags
Mar 24, 2020 06:11 PM|GeorgeTheCoder|LINK
Then what would be the recommended way to get the content from the nested tags?
All-Star
58174 Points
15650 Posts
Re: get content in div tags
Mar 24, 2020 07:54 PM|bruce (sqlwork.com)|LINK
trival:
Contributor
3730 Points
1412 Posts
Re: get content in div tags
Mar 25, 2020 02:48 AM|yij sun|LINK
Hi GeorgeTheCoder,
Accroding to your description,as far as I think,the div of buyer_credit_information is a child of the div of Sales.So,you could each the div of Sales to find the div of buyer_credit_information .Also,I suggest you could use child selector (>) for select the child.This will select all children of divs using the context of #Sales.
More details,you could refer to below codes:
<script src="Scripts/jquery-3.4.1.min.js"></script> <script> $(function () { $("#Button1").click(function () { var x = $("div > div > div", "#Sales").text(); alert(x); }) }) </script> <asp:Button ID="Button1" runat="server" Text="Button" /> <div id="Sales" style="display:none"> <div id="SalesType">-- static content (new, used)</div> <div id="Application"> <div class="BuyerInformation"> <div class="buyer_credit_information"> -- content need to output to file </div> </div> </div> </div>
Result:
Best regards,
Yijing Sun
Member
2 Points
30 Posts
Re: get content in div tags
Mar 25, 2020 12:27 PM|GeorgeTheCoder|LINK
Would this work the same if the div tags had textboxes, dropdowns, etc? and getting those values? Something like this:
This is a dynamic form, so there can be 1 section or multiple sections with elements in the sections
Member
2 Points
30 Posts
Re: get content in div tags
Mar 25, 2020 08:01 PM|GeorgeTheCoder|LINK
Got it working, had to change some of the div tags due to duplicate names in the hidden fields.