我對onmouseevent表單元格有問題。 我在做什麼是刪除和jQuery的幫助下創建HTML表格單元格。當頁面加載這個事件觸發完全罰款。但是在刪除並重新插入表格單元格之後,不會觸發onmouseover事件。下面是我做了什麼代碼...onmouseover事件不是爲表單元格發射
var ModularAdHolderCell = '';
var MergedCellValues = new Array();
$('#our_table tr').each(function (i, el) {
for (var cellCnt = 0; cellCnt < this.cells.length; cellCnt++) {
if ($(this.cells[cellCnt]).attr('class') == 'highlighted' || $(this.cells[cellCnt]).attr('class') == 'OrangeBackground highlighted') {
var id = $(this.cells[cellCnt]).attr('id');
ModularAdHolderCell = id;
id = 'hdn_' + id;
var MergedCells = $(this.cells[cellCnt]).find('input:hidden').val();
if (MergedCells != '')
MergedCellValues = MergedCells.trim().split('=');
}
}
});
var row = document.all.our_table.rows[0];
var TotalCellInRow = row.cells.length;
var Cell = row.insertCell(TotalCellInRow);
var element1 = document.createElement("input");
element1.type = "hidden";
element1.id = "hdn_" + MergedCellValues[cnt];
row.cells(TotalCellInRow).setAttribute('onmouseover', 'MOuseOver(this)');
row.cells(TotalCellInRow).setAttribute('onmouseout', 'MouseOut()');
row.cells(TotalCellInRow).setAttribute('onmousemove', 'MOuseOver(this)');
row.cells(TotalCellInRow).setAttribute('onmouseenter', 'MOuseOver(this)');
row.cells(TotalCellInRow).setAttribute('unitheight', Unitwidth);
row.cells(TotalCellInRow).setAttribute('unitwidth', UnitHeight);
row.cells(TotalCellInRow).setAttribute('id', MergedCellValues[cnt]);
row.cells(TotalCellInRow).setAttribute('width', Unitwidth);
row.cells(TotalCellInRow).setAttribute('height', UnitHeight);
row.cells(TotalCellInRow).appendChild(element1);
$(row).find('#' + MergedCellValues[cnt] + '').attr('onmouseover', 'MOuseOver(this)');
$(row).find('#' + MergedCellValues[cnt] + '').attr('onmouseout', 'MouseOut()');
$(row).find('#' + MergedCellValues[cnt] + '').attr('onmousemove', 'MOuseOver(this)');
$(row).find('#' + MergedCellValues[cnt] + '').attr('onmouseenter', 'MOuseOver(this)');
這裏MergedCellValues是小區ID的陣列和上面的代碼是在電池的循環。
任何人都可以告訴爲什麼它不會觸發onmouseover事件的細胞?
@Ronak;對於這樣的問題,指定你正在測試的瀏覽器幾乎總是至關重要的;它可能會提供有關正在發生的事情的線索。 – BeemerGuy 2010-11-20 10:53:56
你的'MOuseOver'函數是什麼樣的? – 2010-11-20 10:54:21
@BeemerGuy:我正在使用IE8。奇怪的是,它的Safari瀏覽器工作正常。 – Ronak 2010-11-20 11:02:18