I have this html code:
I want to $.get a .txt file with the same name as the div id and show in the respective divs
But is returning the same file to all the divs, also is loading the last file/div id.
How can I achieve this?
<div class="addId" id="qwerty" ><div class="parent"></div></div>
<div class="addId" id="ytrewq" ><div class="parent"></div></div>
<div class="addId" id="asdfgh" ><div class="parent"></div></div>
<div class="addId" id="bruno" ><div class="parent"></div></div>
and this script:
function loadTxt(){
$('.parent').each(function(){
var txtId = $(this).parent().attr('id');
$.get( "./"+txtId+'.txt', function( data ) { var resourceContent = data;
$('.parent').html(data)}) }) };
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…