我有一個對話框,它執行依賴於三個輸入字段的計算。當它們中的任何一個被改變時,它檢查它們是否全部被填滿,以及它們是否是過程並給出其響應。jQuery .change()事件在IE中未觸發
它在FF,Chrome,Opera等工作絕對正常,但在任何版本的IE中它只是停止工作。我的其餘jQuery工作正常,但我無法確切地確定問題出在哪裏。我認爲這可能是與.change()事件或多個事件綁定,但我真的不知道。
這裏是有問題的代碼:
var loan = $("#ltv-loan-amount");
var mortgage = $("#ltv-mortgage");
var property = $("#ltv-property");
$("#ltv-dialog input").change(function() {
if(loan.val() && mortgage.val() && property.val())
{
var ltv = parseInt(((parseInt(loan.val()) + parseInt(mortgage.val()))/parseInt(property.val()))* 1000);
ltv /= 10;
if(ltv > 0 && ltv < 85)
{
$("#ltv-result").html("<span id=\"ltv-form-result\">" + ltv + "%</span></p><p><a id=\"ltv-link\" href=\"#sidebar-head\">Congratulations, your LTV has passed. Please now proceed with your application opposite.</a>");
$("#amount").val(loan.val());
$("#mortgage_balance").val(mortgage.val());
$("#prop_value").val(property.val());
$("#ltv-link").click(function() {
$("#ltv-dialog").dialog("close");
});
}
else if (ltv > 84)
{
$("#ltv-result").html("<span id=\"ltv-form-result\">" + ltv + "%</span></p><p>Unfortunately your LTV is greater than 85%. You may still qualify for a loan if you reduce the loan amount.");
}
else
{
$("#ltv-result").html("</p><p>Please check your input above as you currently have a negative ltv.");
}
}
});
,問題中的HTML:
<div id="ltv-dialog" title="Do You Qualify for a Loan?">
<p>Please enter the fields below and your LTV will be calculated automatically.</p>
<div id="ltv-form">
<div class="ltv-row">
<label for="ltv-loan-amount">Loan Amount:</label>
<input type="text" name="ltv-loan-amount" id="ltv-loan-amount" class="p000" />
</div>
<div class="ltv-row">
<label for="ltv-mortgage">Mortgage Value:</label>
<input type="text" name="ltv-mortgage" id="ltv-mortgage" class="p000" />
</div>
<div class="ltv-row">
<label for="ltv-property">Estimated Property Value:</label>
<input type="text" name="ltv-property" id="ltv-property" class="p000" />
</div>
</div>
<div class="ltv-row">
<p>Loan to Value % (LTV): <span id="ltv-result"></span></p>
</div>
</div>
的更新
變化事件似乎是射擊,但文字只有當框從值更改爲空。
你檢查錯誤控制檯? – 2012-03-29 08:15:22
我認爲以下職位將幫助你: [http://stackoverflow.com/questions/208471/getting-jquery-to-recognise-change-in-ie][1] [1]:http://stackoverflow.com/questions/208471/getting-jquery-to-recognise-change-in-ie – pascalvgemert 2012-03-29 08:15:33
請顯示相關的HTML。如果您使用單選按鈕或複選框,那麼您可能想要聽'.click()'而不是'.change()'。 – jfriend00 2012-03-29 08:16:13