JSFiddle - React, Tailwind, and code Playground

by YOO YEONGHWAN

HTML

<br><span class='zex' cur='KRW'>1000</span>


<script src='//code.jquery.com/jquery.min.js'></script>
<script>
if($(".zex")[0]){
	$.getJSON('https://api.exchangeratesapi.io/latest?base=USD')
	.done(function(data){
		$('.zex').each(function() {
			var cur = $(this).attr('cur');
			if( cur == undefined ) return;
			var old = $(this).text();
			var num = Math.ceil(old.match(/\d+/)[0]/data.rates[cur]);
			num = num.toFixed(2).replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,')
			$(this).html( old + ' (ě•˝ '+ num +'$)');
		})
	})
}
</script>