1

Here is my code for generate combobox. How can I add a css class name 'chosen-select' on it ?

var cell3 = row.insertCell(2);    
var element2 = document.createElement("select");   

var option1 = document.createElement("option");   
option1.value="";   
option1.innerHTML="--Select--";      
element2.appendChild(option1);   

var option2 = document.createElement("option");   
option2.value="1";   
option2.innerHTML="Apple";     
element2.appendChild(option2);   

element2.name = "description" + rowno;  
element2.id = "description" + rowno;   
element2.setAttribute("required","true");   
element2.style.width = "150px";   
cell3.appendChild(element2);   
0

1 Answer 1

6

You can use className property :

element2.className = "chosen-select";

Documentation

Sign up to request clarification or add additional context in comments.

10 Comments

thanx for your reply but its not working....
It is. You must have mistaken somewhere. Where did you put this line ?
element2.name = "description" + rowno; element2.id = "description" + rowno; element2.setAttribute("required","true"); element2.style.width = "150px"; element2.className = "chosen-select"; cell3.appendChild(element2);
i am using that line on above code pls check it is right???
Works fine for me : jsfiddle.net/wmubg. Have you checked for javascript errors ?
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.