0

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!

2
Contributors
1
Reply
2
Views
10 Years
Discussion Span
Last Post by sillyboy
0

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

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

Hope this helps.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.