0

How can i convert css in jquery.I tried but it is not working. Please help anyone.

CSS:

#conpanel .cont .bs{
 background-color:#fff !important;
 border: 0px solid #ccc !important;
 border-width: thin 0px 0px 0px 0px  !important;
 padding: 3px 0 1px 22px !important;
}

#conpanel .cont.bg{
border-bottom: 0px solid #99bbd4;
border-top: medium none;}

Jquery:

   $('#conpanel .cont .bs').attr('style', 'padding: 3px 0 1px 32px !important','border-width: thin 0px 0px 0px 0px  !important');   
   $('#conpanel .cont .bs').css({ 'background-color':'#fff !important','border': '0px solid #ccc !important'}); 
   $('#conpanel .cont .bs').css({'border': '0px solid #ccc !important'});

   $('#conpanel .cont .bg').css({'border-bottom': '0px solid #99bbd4','border-top': 'medium none'});

3 Answers 3

1

just use this and it will do the trick:

$('.bs').css('border-bottom','0px solid #99bbd4');
Sign up to request clarification or add additional context in comments.

Comments

0

For the last line, your selector is wrong. I also added the first batch into one:

$('#conpanel .cont .bs').css({
    'background-color': '#fff !important',
    'border': '0px solid #ccc !important',
    'border-width': 'thin 0px 0px 0px 0px !important',
    'padding': '3px 0 1px 22px !important'
});    

$('#conpanel .cont.bg').css({
  'border-bottom': '0px solid #99bbd4',
  'border-top': 'medium none'
});

Note, I changed #conpanel .cont.bg. These overrides will set inline styles, so you probably don't need the 'important', depending on the context, as they will override the rules you set already.

6 Comments

can u change for all?
Added the first one there, is that what you were looking for?
Possible because the !important was removed, do you need it from the original rules or can they be removed?
Added !important back in, I'd be surprised if that didn't work.
Okay, well if you can't provide any more details I can't help any more.
|
0

Your syntax looks correct. I think it could possibly be that you are using !important in your css file as well as trying to set it with jQuery. Try removing !important from the css file and see if that fixes it.

Html:

<div id="alter-div">
    <p>My Div</p>    
</div>

Here's the jQuery part:

$("#alter-div").css({

  "background-color": "blue",
  "border": "1px solid black",
  "border-top": "1px solid red"

});

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.