Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 6th, 2004, 09:57 AM
Authorized User
 
Join Date: Jun 2003
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to tgopal
Default Setting stylesheet for dynamically created object

Hai
I created a select option(combo box) dynamically using javascript. I want to set the stylesheet class for that. so any one can tell how we can do it

the code i tried

var el = document.createElement('select');
el.setAttribute('name','os');
var newOptionElement = document.createElement("option");
newOptionElement.setAttribute("value", "value");
newOptionElement.innerHTML = "value";
el.appendChild(newOptionElement);
el.style.className='text'
i defined text in my css as following

.font8ptNorm {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 11px;
    color: #333333;
}


Thanks
T.Gopalakrishnan

 
Old September 6th, 2004, 10:47 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Use 'className' directly, <object>.className, not <object>.style.className.

--

Joe
 
Old September 6th, 2004, 11:47 PM
Authorized User
 
Join Date: Jun 2003
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to tgopal
Default

Thanks Joe Fawcett. Its working






Similar Threads
Thread Thread Starter Forum Replies Last Post
Please help me about dynamically created controls vingo_mail ASP.NET 2.0 Basics 1 March 24th, 2008 12:54 PM
Setting onChange Event w/Dynamically Created Form rvanandel Javascript How-To 4 June 28th, 2007 08:10 AM
Dynamically created code Puck312 Pro VB 6 3 September 7th, 2005 01:21 PM
Dynamically created controls katsarosj ASP.NET 1.0 and 1.1 Basics 4 February 4th, 2004 09:13 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.