0

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%;
}
7
  • 1
    What's the position value for your CSS? top won't work with static Commented May 9, 2011 at 9:27
  • 1
    is .result position: relative or absolute? Commented May 9, 2011 at 9:28
  • 2
    wait, do you want to update the elements of the class .result or the class itself? I don't think the second is possible, but also not necessary since the first has the same effect Commented May 9, 2011 at 9:49
  • 1
    can you post your HTML? The snippet you posted is correct Commented May 9, 2011 at 9:50
  • 1
    You don't seem to be applying the result class to the actual DIV? Commented May 9, 2011 at 10:01

2 Answers 2

1
      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

Sign up to request clarification or add additional context in comments.

Comments

1

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

take a look to this articles:

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.