2017-07-28 50 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值。