Skizit
Skizit

Reputation: 44862

How to change class CSS using jquery

I'm attempting to edit my classes CSS (div.result) using the following...

$('.result').css('top', '55%');

however, it doesn't appear to be updating.. any ideas why? What am I doing wrong?

Below is the relevant CSS. The Javascript I'm using and the javascript which renders the div resides in cr.js.

HTML

 <div id='cr' style='width:510px; height:440px; display:none; overflow:auto'>
    <script src = "js/c.js"></script>
</div>

CSS

div.result {
position: absolute;
top: 20%;
}

Upvotes: 0

Views: 136

Answers (2)

insoftservice
insoftservice

Reputation: 840

      1>  $('#cr').removeClass('.result');
      2>    $('#cr').addClass('.result_top');
css

div.result_top {

div.result_top { over here you can put your new css. }

if u just want to append the css such as

div.result top{ }

than just remove line 1 it would do the work

Upvotes: 1

Flavio CF Oliveira
Flavio CF Oliveira

Reputation: 5295

Use the jquery ".removeClass" / ".addClass" methods.

take a look to this articles:

http://api.jquery.com/addClass/

http://api.jquery.com/removeClass/

Upvotes: 1

Related Questions