比特币代码+ fontawesome
问题描述:
我的任务是编写一个函数,从JSON链接获取比特币交易,更改按钮间隔,添加fontawesome箭头向上/向下/线取决于速率上升/下降/没有变化,并显示它网站。比特币代码+ fontawesome
我除了fontawesome一切......
我的HTML代码:
<h3>Bitcoin to PLN</h3>
<h4>Buy</h4>
<div id="buy"><p></p></div>
<h4>Sell</h4>
<div id="sell"><p></p></div>
<h4>Refresh in:</h4>
<form name="timerBtn">
<input type="button" class="button" id="btn5" value="5 s">
<input type="button" class="button" id="btn10" value="10 s">
<input type="button" class="button" id="btn30" value="30 s">
<input type="button" class="button" id="btn60" value="60 s">
</form>
<p id="timer">Refreshing in 5 sekund</p>
和JS:
$("form").click(function(getTimer) {
if (getTimer.target.className === 'button') {
$("p#timer").empty();
var timer = $("p#timer").append("Refresh in " + getTimer.target.value);
}
return timer
});
function startRefresh() { $.getJSON("https://blockchain.info/pl/ticker", function (data) {
$("#buy").html(data.PLN.buy);
$("#sell").html(data.PLN.sell);
console.log ("reupload");
});
}
setTimer = setInterval(startRefresh, 5000);
$("input#btn5").click(function() {
clearInterval(setTimer);
setTimer = setInterval(startRefresh, 5000);
});
$("input#btn10").click(function() {
clearInterval(setTimer);
setTimer = setInterval(startRefresh, 10000);
});
$("input#btn30").click(function() {
clearInterval(setTimer);
setTimer = setInterval(startRefresh, 30000);
});
$("input#btn60").click(function() {
clearInterval(setTimer);
setTimer = setInterval(startRefresh, 60000)
});
我不知道该如何处理fontawesome部分
在此先感谢您的任何提示
答
字体真棒向上箭头显示是这样的:
<i class="fa fa-arrow-up"></i>
我将所有的HTML片段(上,下和没有变化)存储到自己的变量。
upArrow = '<i class="fa fa-arrow-up"></i>'
然后当你注入这样的startRefresh
功能的HMTL将它们注入:
$("#buy").html(upArrow + data.PLN.buy);
有[上字体真棒例子(http://fontawesome.io/examples/)现场。 – Tigger
好的,但如何更改箭头如果显示的值比刷新前的值大/低? –