Saved X
Google login
SignUp with Email
X

Remove all inline css jquery

theindreshverma ( Edited  Sep 29, 03:37 pm )
Login

Jquery attr() method, set style attribute value '' or remove style attribute using removeAttr() method.

<html>
<head>
    <title>Remove all inline css</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>

<h1>Remove all inline css</h1>

<div id="d" style="border: 1px solid #ccc;margin-bottom: 20px">
    <p>This is paragraph.</p>
</div>

<button id="r">Remove css</button>

<script>
$('#r').click(function() {
    $('#d').attr('style', '');
    
    // remove this attribute
    
    // $('#d').removeAttr('style');
});
</script>

</body>
</html>

Sourcecode Tags

More Sourcecodes

More Sourcecodes