I am trying to get a Javascript stock ticker to work, it is going well but my knowledge of Javascript is at a beginner level - but I'm learning!
- The current code pulls out live stock data using the google finance API.
- It checks to see the stock acronym and prints the full company name
- and has some various styling
What I am trying to accomplish is to get the stock data to print out in columns, I cant seem to do this in html and after looking at Javascript tables I think this needs to be written as Javascript.
I need to create 3 columns; 1 for the stock name e.g. (HAULOTTE), one for the stock acroynm eg (PIG) and one for the live stock figures. This will ensure each stock data row keeps parallel with the one above and below it.
Attached is the current jsfiddle:
https://jsfiddle.net/feq3L57p/
var gstock = ["EPA:PIG","LON:AHT","NYSE:URI","NYSE:TEX" ,"NYSE:CAT", "NASDAQ:HEES", "NASDAQ:MNTX", "VIE:PAL" ];
$(document).ready(function () {
for (var i = 0; i < gstock.length; i++) {
$.getJSON("https://finance.google.com/finance/info?client=ig&q="+gstock[i]+"&callback=?", function (response) {
var stockInfo1 = response[0];
var divContainer = $('*[data-symbol="' + stockInfo1.t +'"]');
var stockString1 = '<div class="stockWrapper">' + divContainer.data('title') + ':';
var stockName1 = stockInfo1.t;
stockString1 += '<span class="stockSymbol "> ' + stockInfo1.t + ' </span>';
stockString1 += '<span class="stockPrice "> ' + stockInfo1.l + '</span>';
stockString1 += '<span class="stockChange "> ' + stockInfo1.c + '</span>';
stockString1 += '</div>';
divContainer.append(stockString1);
});
}
});