Change CSS rule in class using JQuery

前端 未结 8 1347
我在风中等你
我在风中等你 2020-12-05 04:40

I have a class in CSS

.Foo
{
  width:20px;
}

Using Jquery I would like to do something similar to this on an event:

$(\".Fo         


        
相关标签:
8条回答
  • 2020-12-05 05:30

    You should be selecting an element with jQuery. You're aware that you aren't selecting the CSS class itself, correct?

    Once you have an element with class="Foo", you can select it as you have, and either set css properties manually like you're trying to do, or you can use add class like so:

    $(".Foo").addClass('Foo');

    Granted of course, since you're selecting the same class that you're adding, it doesn't really make sense.

    0 讨论(0)
  • 2020-12-05 05:43

    I got thsi example in CSS api help in JQuery API.

    this worked for me : http://jsfiddle.net/LHwL2/

    for complete help read the css api at http://api.jquery.com/css/

    0 讨论(0)
提交回复
热议问题