<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<div class="col-sm-12 m-auto bg-light p-2">
<p>For more detail check the link.</p>
<p><a href="https://learncodeweb.com/jquery/how-to-get-html-attribute-values-in-jquery/" target="_blank">How to get HTML attribute values in JQuery</a></p>
<img src="https://via.placeholder.com/250x250" class="img-thumbnail" id="img" alt="image" />
<div class="mt-1">
<input type="submit" class="btn btn-primary" id="btn" value="Set Attribute">
<input type="reset" class="btn btn-danger" id="removebtn" value="Remove Attribute">
</div>
</div>
$(document).ready(function(){
$('#btn').on("click",function(){
$('#img').attr({
'src':'https://learncodeweb.com/wp-content/uploads/2019/01/php.jpg',
'width':'250',
'height':'250',
'title':'Add or Remove multiple Attributes with JQuery'
});
});
$('#removebtn').on("click",function(){
$('#img').attr('src','https://via.placeholder.com/250x250');
$('#img').removeAttr('width height');
});
});
This Pen doesn't use any external CSS resources.