2017-09-03 2 views
0

내 작업은 JSON 링크에서 Bitcoin 거래를 가져오고, 버튼으로 간격을 변경하고, fontawesome 화살표를 위/아래/선을 추가하는 기능입니다. 속도가 위/아래/변경 없음에 따라 달라지며 표시됩니다. 웹 사이트.Bitcoin ticker + fontawesome

<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 : 나는 fontawesome 부분

처리하는 방법을 모르는

$("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) 

}); 

나는

내 HTML 코드는 ... fontawesome 제외한 모든이

미리 감사드립니다.

+0

[글꼴 신난다의 예]가 있습니다 (http://fontawesome.io/examples/) 대지. – Tigger

+0

그래도 표시되는 값이 새로 고침 전의 값보다 크거나 작 으면 화살표를 변경하는 방법은 무엇입니까? –

답변

1

글꼴 최고 화살표 위로는 다음과 같이 표시됩니다

<i class="fa fa-arrow-up"></i> 

나는 자신의 변수에 모든 (아래, 그리고 변화 없음) 그 HTML 미리보기를 저장하는 것입니다. 다음

upArrow = '<i class="fa fa-arrow-up"></i>' 

그리고이 같은 startRefresh 함수에서 HMTL를 주입 할 때를 주입 :

$("#buy").html(upArrow + data.PLN.buy);