User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 456,539 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,158 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1022 | Replies: 1
Reply
Join Date: Oct 2007
Location: Baltimore/DC
Posts: 33
Reputation: Tom Tolleson is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
Tom Tolleson's Avatar
Tom Tolleson Tom Tolleson is offline Offline
Light Poster

Applying CSS to new objects

  #1  
Oct 11th, 2007
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!
Last edited by Tom Tolleson : Oct 11th, 2007 at 12:03 pm.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Mar 2007
Location: Brisbane, Australia
Posts: 227
Reputation: sillyboy is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 13
sillyboy's Avatar
sillyboy sillyboy is offline Offline
Posting Whiz in Training

Re: Applying CSS to new objects

  #2  
Oct 12th, 2007
Is this just an issue with IE? If so try adding the following line.

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

Hope this helps.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 4:52 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC