Reputation: 3071
I need with jquery to update value in span
<p id="my_balance"><span class="pr-1">EUR</span> 999,999.99</p>
If I make it with code
$("#my_balance").html(formatted_balance);
san is not updated. If I make it :
$("#my_balance > span").html(formatted_balance);
Value is written AFTER tag and I have 2 values old and current. Which is valid way ?
Thanks!
Upvotes: 1
Views: 379
Reputation: 763
I hope this will help. Try to make the simplest example, so that you understand how you target the element in jQuery.
$(document).ready(function(){
$("#my_balance").find("span.pr-1").text("YEN"); // pass your Currency type
//You can also use html Just uncomment the below line to test.
//$("#my_balance").find("span.pr-1").html("<strong>YEN</strong>");
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<p id="my_balance"><span class="pr-1">EUR</span> 999,999.99</p>
Upvotes: 0
Reputation: 335
Try to write like this
let myBalance = $("#my_balance");
let span = myBalance.find("span");
myBalance.html('New Text');
myBalance.prepend(span);
Replace New Text with the value you need
Upvotes: 1