I don't need to use Yahoo Finance api or such. Simply multiply the numbers by a fixed amount.
See codepen. Dropdown functionality is not implemented, I want to have the exchange down first. I know this is just the start, but how to go on? This obviously needs several problems to be solved:
- This currently changes every value to the same
- I need the ability to change them back when selecting the USD again
- Is it too inefficient to not give classnames, but find all the prices (contains $ or €) automatically?
Could you give me some pointers how should I go on, please?
$(document).ready(function() {
// $('select').material_select();
$('.caret').text(" ");
//here starts my attempt for the exchange
var price = $(".price").text().replace("$", "");
var convertedToNumber = parseFloat(price);
var eurPrice = convertedToNumber / 1.18;
$(".price").text(eurPrice);
});
input.select-dropdown {
color: #26a69a;
}
.caret {
background:url("http://svgshare.com/i/3Bc.svg") no-repeat 90% 50%;
width:20px;
height:auto;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<div class="row">
<div class="input-field col s1">
<select>
<option value="1" selected>USD</option>
<option value="2">EUR</option>
</select>
<label>Currency</label>
</div>
</div>
<ul class="currencies">
<li class="price">$1500</li>
<li class="price">$2000</li>
<li class="price">$342</li>
</ul>