我想檢查複選框時調用html頁面。我嘗試了以下jQuery代碼,但它不起作用。我犯了什麼錯誤?如何使用jQuery調用複選框更改的html頁面?
<script type="text/javascript">
$('#my_checkbox').change(function() {
alert('Handler for .change() called.');
$.get("equation_section.html");
});
</script>
這是我的複選框:
<input class="checkbox" type="checkbox" name="my_checkbox" id="my_checkbox"/>
編輯
$('#my_checkbox').change(function() {
if ($('#my_checkbox').attr("checked") == true) {
alert('Handler for .change() called.');
$('#my_checkbox').addClass('jQlightbox');
$.get('equation_section.html', function(data) {
$('.equation_section').html(data);
});
}
});
這是我編輯的代碼。現在我收到警報框。該頁面也被加載到div中。如果我只想將div內容顯示在模式窗口上而不是之前的頁面內容怎麼辦?有人建議我。
「被叫」是什麼意思? – sdleihssirhc 2011-04-01 05:38:55
我想要加載其他頁面,即方程section.html。 – Angeline 2011-04-01 05:41:12