テーブルセルのonmouseeventに問題があります。 私がやっていることは、jqueryの助けを借りてhtml table cellを削除して作成することです。ページがロードされると、このイベントは完全に正常に発生します。しかし、同じ位置に再びテーブルセルを取り出して挿入しても、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
あなたの 'MOuseOver'関数はどのように見えますか? –
@BeemerGuy:私はIE8を使用しています。奇妙なことは、サファリのためにうまくいきます。 – Ronak