There is code for only one div. I need to apply this function to other divas with different id.
I change the parameters in the function and nothing happens, only one of them works or not one at all. what to do
var price1; var reloadData = function() { $.getJSON('https://api.cryptonator.com/api/ticker/btc-usd', function(data){ var float1 = parseFloat(data.ticker.price).toFixed(2) if(price1 && price1 > float) { $('#result1').html('<font color="red">' + float1 + '</font>') } else if(price1 && price1 < float1) { $('#result1').html('<font color="green">' + float1 + '</font>') } else { $('#result1').text(float1) } price1 = float1 }) } setInterval('reloadData()', 5000) $(document).ready(reloadData) var price2; var reloadData = function() { $.getJSON('https://api.cryptonator.com/api/ticker/ltc-usd', function(data){ var float2 = parseFloat(data.ticker.price).toFixed(2) if(price2 && price2 > float2) { $('#result2').html('<font color="red">' + float2 + '</font>') } else if(price2 && price2 < float) { $('#result2').html('<font color="green">' + float2 + '</font>') } else { $('#result2').text(float2) } price2 = float2 }) } setInterval('reloadData()', 5000) $(document).ready(reloadData) <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="result1">Loading...</div> <div id="result2">Loading...</div>