一千萬個為什麽

搜索

Jquery在IE 8中不起作用

我在jquery中創建了一個代碼,用於在Page中動態添加組件

var counter = 1;
var delCnt = 0;
$(function() {
    $('#linkAddLot').click(function() {
        counter = eval(document.getElementById("hdnTotLot").value);
        delCnt = eval(document.getElementById("hdnDelLot").value);
        if((eval(counter-delCnt))>=5){
            $('span.#lotMsg').css("visibility","visible");
            $('span.#lotMsg').css("color","red");
            $('span.#lotMsg').html('Already 5 (Five) Lot!!!');
        } else {
            $('span.#lotMsg').css("visibility","collapse");
            var htmlEle = "<tr id='trLot_"+ (counter+1) +"'>"+
                "<td class='t-align-center'><input type='checkbox' name='packagedetail_"+ (counter+1) +"' id='chkPackageDetail_"+ (counter+1) +"' value='"+ (counter+1) +"'/></td>"+
                "<td class='t-align-center'><input name='lotno_"+ (counter+1) +"' type='text' class='formTxtBox_1' id='txtLotNo_"+ (counter+1) +"' style='width:80px;' onBlur='chkLotNoBlank(this);chkLotNo(this);'/> </td>"+
                "<td class='t-align-center'>

 </td>"+
                "<td class='t-align-center'><input name='quantity_"+ (counter+1) +"' type='text' class='formTxtBox_1' id='txtQuantity_"+ (counter+1) +"' style='width:80px;' onBlur='chkQtyBlank(this);'/> </td>"+
                "<td class='t-align-center'><input name='unit_"+ (counter+1) +"' type='text' class='formTxtBox_1' id='txtUnit_"+ (counter+1) +"' style='width:80px;' onBlur='chkUnitBlank(this);'/> </td>"+
                "<td class='t-align-center'><input name='estimatecost_"+ (counter+1) +"' type='text' class='formTxtBox_1' id='txtEstimateCost_"+ (counter+1) +"' style='width:80px;' onChange='setPkgEstCost(this);' onBlur='chkEstBlank(this);'/> </td>"+
                "</tr>";
            $("#tblLots").append(htmlEle);
            document.getElementById("hdnTotLot").value = (counter+1);
        }
    });
});

這裏我在 onBlur ='chkLotNoBlank(this); chkLotNo(this);' on txtLotNo上做了onBlur函數,但是在IE8中它無法工作,

如果我將在IE 7和Firefox運行它我工作正常,並且如果我將在Windows 7預安裝IE8版本IE8.0.7600.16385工作,但它不能工作,如果我將嘗試在Windows 2003兼容IE 8.0.6001.18702那麽有人能給我解決這個問題嗎?

最佳答案

您有以下代碼:

$('span.#lotMsg').css("visibility","visible"); 
$('span.#lotMsg').css("color","red"); 
$('span.#lotMsg').html('Already 5 (Five) Lot!!!');

將此縮短到以下情況不是更好嗎

$('span.#lotMsg').css("visibility","visible").css("color","red").html('Already 5 (Five) Lot!!!'); 

轉載註明原文: Jquery在IE 8中不起作用