A
A
Alexander Sinitsyn2015-11-05 18:42:21
css
Alexander Sinitsyn, 2015-11-05 18:42:21

How to remove specific css rule from style attribute?

I add The style attribute changes. And how to remove the added styles? If you put some value of type none, then it starts to overlap the value from the class. Is there any way to do without reading attr('style') and writing it back after "manual" clearing?
$('...').css('prop', 'value')


Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Konstantin Gromov, 2015-11-05
@a_u_sinitsin

// jQuery
$("#element").css("width", "");

// Native
document.querySelector("#element").style.width = "";

M
Maxim Nepritimov, 2015-11-06
@nepritimov_m

It seems to me that we need to play less with this addition of styles. It is much more convenient to add a css class defined in advance:
And then, if necessary, remove the class:
$('...').removeClass('my-class');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question