0
I need to take the value of a data-attr that is generated from an ajax request.
The most I got was:
$('.dataImposto').on('click', '.ImpostodeRenda', function(){
$(".ImpostodeRenda").html("ooi");
});
The problem is that this "Impostoderenda" is generated dynamically from an ajax return.
Return of the Ajax
dados = $.parseJSON(data);
$.each(dados,function (key) {
$(".dataImposto").append(" <div class='row static-info align-reverse'> <div class='col-md-8 name '>"+dados[key].nome+" ("+dados[key].valor+"%)</div> <div i class='col-md-3 value imposto "+dados[key].nome.replace( /\s/g, '' ) + "' data-class="+dados[key].nome.replace( /\s/g, '' )+" data-imposto="+dados[key].valor+" > </div> </div>");
});
Example of generated HTML
<div class="dataImposto">
<div class="row static-info align-reverse">
<div class="col-md-8 name "> DAS(11.50 % )
</div>
<div id="imposto" class="col-md-3 value DAS" data-class="DAS" data-imposto="11.50"> </div>
</div>
<div class="row static-info align-reverse">
<div class="col-md-8 name ">Imposto de Renda (15.00%)</div>
<div id="imposto" class="col-md-3 value ImpostodeRenda" data-class="ImpostodeRenda" data-imposto="15.00">
</div>
</div>
</div>
Look who’s born DAS...
I wanted to take the data-class and the tax date of both.
Thank you in advance
Nice, but here’s the deal. I have a div with "timeTime" the content of the return of the ajax is placed inside that div, with the code I showed above. This ajax is sent when I press a button.
– gabrielfalieri
You want to send this value as ajax parameter?
– Rafael Augusto
No, I want to redeem the value of the data-attr that comes created with the return of ajax, within the div
– gabrielfalieri
So just do it the way I did it up. In case it didn’t work anyway, explain to me better that I help you solve.
– Rafael Augusto
It’s my time for class, is it okay to call you tomorrow? has Skype or something?
– gabrielfalieri
Came, good morning, I got to add you on Skype
– gabrielfalieri
I had to make a small adaptation but the idea of taking one that already exists for everyone worked out cool
– gabrielfalieri