function changediv2(){
content = document.getElementById("jingpaidiv");
var price = document.getElementById("price").value;
var jingpaiPrice = document.getElementById("jingpaiPrice").value;
if(jingpaiPrice>price){
content.style.display ='none';
return true;
}else{
alert("您填写的竞拍价格必须大于现在的竞拍价!请重新填写!谢谢");
 return false;
}

} 为什么当 jingpaiPrice 的值大于1000的时候price 的值小于1000的时候总是alert呢!

解决方案 »

  1.   

    if ((new Number(document.getElementById("jingpaiPrice").value)).valueOf() > (new Number(document.getElementById("price").value)).valueOf()){
      

  2.   

    你现在比的就是字符串!!if(parseFloat(jingpaiPrice)>parseFloat(price))
      

  3.   

    function changediv2(){
    content = document.getElementById("jingpaidiv");
    var price = parseInt(document.getElementById("price").value);
    var jingpaiPrice = parseInt(document.getElementById("jingpaiPrice").value);
    if(jingpaiPrice>price){
    content.style.display ='none';
    return true;
    }else{
    alert("您填写的竞拍价格必须大于现在的竞拍价!请重新填写!谢谢");
    return false;
    }

    //你这样试试
      

  4.   

    谢谢!第一次在CSDN问问题!一人十分!最后采用3楼的方法!请以后多多指教!谢谢!