0

I want to remove the inline and external css applied to the particular div.

I don't want to use remove_all_styles() which removes all the styles of the page.

How can I achieve this?

ravindra.kamble
  • 1,023
  • 3
  • 11
  • 20

5 Answers5

1

Does removing both style and class attributes do the trick?

$("#ParticularDiv").removeAttr("class").removeAttr("style");
ZiNNED
  • 2,620
  • 20
  • 31
1

You could try;

$("#div"){
    remove_attributes()
}

Then you would have a blank slate.

Mike Kinghan
  • 55,740
  • 12
  • 153
  • 182
nikkyt
  • 13
  • 5
0

Remove inline css of a particular div

$('#div_id').removeAttr('style');

Or you can do it in your css also bu using not attribute.

In html:

<button class="nostyle">

In css:

button:not(.nostyle) {

Usefull fiddle by Danny Beckett

Moeed Farooqui
  • 3,604
  • 1
  • 18
  • 23
0

You can do that by selecting that div using tritium and then using the attribute(...) function to clear out the style attribute. Say I had the following html:

<html>
  <body>
    <div style="background: red">Hi</div>
  </body>
</html>

I could write the following tritium to remove the inline style:

$("/html/body/div") {
  attribute("style", "")
}

A shortcut to this is using the remove(...) function in tritium. With some XPath magic, you can turn the above code into a one-liner like so:

remove("/html/body/div/@style")

And that should remove the inline styles associated with that div.

noj
  • 2,542
  • 1
  • 14
  • 9
0

You can remove it by $('#div') {remove_atributes()} which will remove all the attributes inside div else you can go for remove_class('ClassName') which will remove class containing style