0

I have a question , is it possible to add property/value to a class created dynamically?

for Ex:

var clss=document.createAttribute('class');

// here can we add property/value to a "clss " like

// clss.someMethod('width' , '100px');

// clss.someMethod('border' , '2px solid red');

// something like this...is it possible ??

div.setAttribute('class' , cls);

I know how to add inline-style , i just want to add it "clss" , is it possible? Thanking you all in advance.

Ram
  • 143,282
  • 16
  • 168
  • 197
Faizy
  • 21
  • 7
  • 1
    No, that's not how class attribute works. You can create a `style` element instead. – Ram Oct 21 '14 at 12:59
  • @Vohuman Not possible? – Faizy Oct 21 '14 at 13:00
  • Don't you want to use "style" and not "class"? – epascarello Oct 21 '14 at 13:00
  • @epascarello If i use style , that would again be inline rite , if i am not wrong :( – Faizy Oct 21 '14 at 13:01
  • 1
    Just saying your example shows styles and you are setting a class. If you want to do something like you want to do, you would need to code a method yourself. – epascarello Oct 21 '14 at 13:02
  • 1
    Also useful: http://stackoverflow.com/questions/5105530/programmatically-changing-webkit-transformation-values-in-animation-rules – joews Oct 21 '14 at 13:07
  • @epascarello pls can u just show me how to do it , it will be very helpfull. I am learning javascript , and i donno from where this idea came in my mind , still a beginner :) – Faizy Oct 21 '14 at 13:07
  • @joews that did help me a bit , though i dint get it fully . thank you (y) – Faizy Oct 21 '14 at 13:10

0 Answers0