I want to remove inline style from a span or div or ...
<span style="font-size: 8pt;">some texts</span>
Can i remove font-size from span with jQuery ?
If you want to remove the entire style
attribute then you can use removeAttr('style');
$('span').removeAttr('style');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span style="font-size: 8pt; color: #c00;">some texts</span>
If you want to override the setting back to default whilst retaining other inline styles, use css('font-size', 'inherit');
$('span').css('font-size', 'inherit');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span style="font-size: 8pt; color: #c00;">some texts</span>
If you want to completely removed the inline styles in any of your html elements.
You can you the removeAttr
method provided by jQuery.
$('span, div').removeAttr('style');
Remove inline style
$('span').removeAttr('style');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span style="font-size: 8px; color: red">some texts</span>
Update multiple property in css
$('span').css({
'font-size' : '20px',
color: 'blue'
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span style="font-size: 8pt;">some texts</span>
Update single property using css
$('span').css('font-size', '20px');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span style="font-size: 8pt;">some texts</span>