How to apply !important using .css()?

后端 未结 30 2986
情深已故
情深已故 2020-11-21 07:06

I am having trouble applying a style that is !important. I’ve tried:

$(\"#elem\").css(\"width\", \"100px          


        
30条回答
  •  野的像风
    2020-11-21 07:38

    I would assume you tried it without adding !important?

    Inline CSS (which is how JavaScript adds styling) overrides the stylesheet CSS. I'm pretty sure that's the case even when the stylesheet CSS rule has !important.

    Another question (maybe a stupid question but must be asked.): Is the element you are trying to work on display:block; or display:inline-block;?

    Not knowing your expertise in CSS... inline elements don't always behave as you would expect.

提交回复
热议问题