Jump to content

Recommended Posts

Hi, I'm building a table with javascript, and i'd like to add a class to the cells,

Adding the class itself works, but if I add an css even like :hover, it refuses to work

 

is there any way to get this to work, without adding onmouseover and onmouseoff events to the cell?

 

The style I want to call is =>

<style>
.myClass:hover{
	background-color:#00cc00;
	border:0px;
	filter:alpha(opacity=25);
	-moz-opacity:.25;
	opacity:.25;
}
</style>

the code building the table is:

var table = document.createElement("table");
	table.style.borderCollapse="collapse";
	var rows = 15; //is loaded from an xml
	var cols = 15; //is loaded from an xml
	for(var i = 0;i < rows;i++){
		var row = table.appendChild(document.createElement("tr"));
		for(var j = 0;j < cols;j++){
			var cell = row.appendChild(document.createElement("td"));
			cell.style.width = "32px";
			cell.style.height = "32px";
			cell.style.margin = "0px";
			cell.style.padding = "0px";
			cell.title = "("+(i+1)+", "+(j+1)+")";
			cell.className = "myClass";
		}
	}

 

what should I do

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.