I want to use javascript and php to make black dots appear on the screen. So far, I have the following code, which isn't working. What am I doing wrong?

function dots() {
    var dot = document.createElement("div");
    dot.style = "position: relative; background-color: #000; height: 10px; width: 10px;";
    document.body.appendChild(dot);
}

Use css instead of dot.style and it will work.

thanks, i will try that :-)

This is even better: just do this short change and it will work in Firefox and IE

dot.style.cssText = "position: relative; background-color: #000; height: 10px; width: 10px;";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.