CSS class not applying properly

I have created som code that allows a user to create an object by clicking a button.
It's working fine.
However, I have a CSS class called "draggable" (which makes the object draggable).

If I apply the class to a hand-coded object:

<form action="#">
    <input type="radio" CLASS="draggable" name="radio" id="radio" />
</form>

It is draggable.

But the objects created by this script:

function makeradio(){
	var newElem= document.createElement("input")
	newElem.type = "radio"
	document.forms[2].appendChild(newElem);
	newElem.setAttribute("class", "draggable")
}

Are not draggable. Any ideas?

Here's the code in its entirety:

<html>
<head>
<script language="JavaScript">
function makeradio(){
	var newElem= document.createElement("input")
	newElem.type = "radio"
	document.forms[2].appendChild(newElem);
	newElem.setAttribute("class", "draggable")
}
</script>

</head>
<body>
	<form>
		<input type="button" src="images\radio_button.gif" onclick="makeradio();" >	
	</form>	
	<br>
	<form>
	</form>
</body>
</html>

Thanks!

Is this just an issue with IE? If so try adding the following line.

newElem.setAttribute("className", "draggable")

Hope this helps.

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.