ฉันไม่รู้ว่าทำไม แต่โค้ดด้านล่างใช้งานได้ใน Firefox แต่ไม่ใช่ใน Google Chrome เพราะเหตุใด นี่ควรเป็น JS มาตรฐาน
status = parseInt($('#input-status').val());
// status field is exactly equals to 0
if (status === 0) {
// do something, in Firefox the code reaches here, in Chrome NOT !
}
นี่คือวิธีกำหนด #input-status ใน html :
<input type="hidden" id="input-status" name="input-status" value="00">
ใน Chrome รหัสจะทำงานเฉพาะในกรณีที่ฉันแทนที่ === โดย ==
มีความคิดอะไรบ้าง?
console.log(typeof status);
ก่อนคำสั่ง if - Chrome บอกว่าเป็นประเภทอะไร - person Anthony Grist   schedule 12.02.2014parseInt($("#input-status").val(), 10);
- person Elliot Bonneville   schedule 12.02.2014