-1

How i can make a dynamic css class without use of id.

$( "#mydiv" ).css( "width", $("#widthtextbox").val() );

$( "#mydiv" ).css( "height", $("#heighttextbox").val() );

i want to use several css class for the work.

Abbas Rahimi
  • 202
  • 1
  • 5
  • 15
  • 3
    what do you mean by 'dynamic css class' ? Did you see this : http://api.jquery.com/addClass/ ? – Istiaque Ahmed Dec 26 '13 at 09:06
  • i have a problem when i use .css() ,this method change my classوWhereas i want reuse this class for another div.and i think this problem is for id. – Abbas Rahimi Dec 26 '13 at 09:09
  • How does it change ? if you have a class `my_class` defined in your style sheet, you can add (`addClass`) it to or remove(`removeClass`) it from any element with jQuery. – Istiaque Ahmed Dec 26 '13 at 09:10
  • I hope you are looking for solution like this (2nd answer). http://stackoverflow.com/questions/6115325/change-css-rule-in-class-using-jquery – Priyank Dec 26 '13 at 09:18

2 Answers2

1

Use class selector

$(".yourclass")

this should solve it

Satpal
  • 132,252
  • 13
  • 159
  • 168
ah-shiang han
  • 330
  • 1
  • 9
1

Use class name for the same,

$(".className").css("","");
Tony Jose
  • 1,654
  • 1
  • 13
  • 25