IE New Element with Style?

carlmagpie

New Member
I have this stylesheet:\[code\].pixel{ position: absolute; height: 10px; width: 10px; background-color: #ffcc00; font-size: 0px;}\[/code\]And this javascript:\[code\]function drawpixel(x,y){ el = document.createElement('div'); el.setAttribute('class','pixel'); el.style.left = x; el.style.top = y; /* IE needs this for some reason? el.style.position = "absolute"; el.style.backgroundColor = "#FFCC00"; el.style.width = "2px"; el.style.height = "2px"; */ el.style.fontSize = "0px"; el.style.lineHeight = "0px"; document.body.appendChild(el);}function mover(event){ element = document.getElementById("coords"); element.innerHTML = event.clientX + " " + event.clientY; drawpixel(event.clientX, event.clientY);} \[/code\]Which allows me to "draw" with divs. But IE requires those 4 commented lines - it won't read the class information for some reason?Is there any easier way to "fix" it for IE, or do I pretty much just have to have those 4 lines?thanks
 
Top