开发者

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%;
}


      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


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

take a look to this articles:

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

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜