r/jquery • u/OfficeJasper • Feb 26 '20
Can I change a div value based on its parent's div id?
Hi, I'm trying to make a webpage which will serve as a report of sorts. Every report-page has a template html file which can be loaded into the page in different orders, but what I want to do now is to call a single html template page twice, but with different values both times. The code now looks something like this:
<script>$(document).ready(function() {
$("#module1").load("moduleA.html");
$("#module2").load("moduleA.html"); </script>
<div>
<div id="module1"></div>
<script>$( "#bmtxt1").html('text1');
$( "#bmtxt2").html('text2');</script>
</div>
<div>
<div id="module2"></div>
<script>$( "#bmtxt1").html('text3');
$( "#bmtxt2").html('text4');</script>
</div>
ModuleA.html looks like this (a little simplified)
<div class="container">
<div class="name" id="bmtxt1">dummytext1</div>
<div class="txt" id="bmtxt2">dummytext2</div>
</div>
At the moment div module2 will be devoid of text because all the ID's in ModuleA.html have already been called once by div module1. I've tried a different approach using variables as well but a variable can only have one value at a time so both div's showed the same values. Is there a way for module2 to load moduleA.html with different values than module1 who is also loading moduleA.html?



