2017-07-28 75 views
1

我打電話給showedit函數帶有參數。但是當我alert它在它顯示部分價值的功能。Javascript函數沒有得到整個值

下面是HTML代碼:

<a href="javascript:void(0)" onclick="showedit(856478546521458789);"> 
    <i class="fa fa-pencil-square-o" aria-hidden="true" style="font-size: 20px;float: right;"></i> 
</a> 

下面是Javascript代碼:

function showedit(id) { 
    alert(id); 
    document.getElementById("update_status_" + id).style.display = "block"; 
    document.getElementById("status_" + id).style.display = "none"; 
} 

你能告訴我是什麼問題?

+2

可能的重複[什麼是JavaScript的最高整數值,數字可以去不失精度?](https://stackoverflow.com/questions/307179/what-is-javascripts-highest-integer-value-that -a-number-can-go-to-without-losin) –

+0

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER – Teemu

+0

也許你應該把它寫成一個字符串,而不是一個數字。 – Stephan

回答

2

將參數作爲字符串發送。請參見下面的代碼片段:

<a href="javascript:void(0)" onclick="showedit('856478546521458789');"> 
    <i class="fa fa-pencil-square-o" aria-hidden="true" style="font-size: 20px;float: right;"></i> 
</a> 

它正在發生,因爲它是超過JavaScript的MAX_INT值。