jQuery addClass example

Change class name on click in jQuery

by abdulpathan

HTML

<div id="banner-message">
  <img id="test" class="test-img">
</div>

CSS

.test-img{
  height:100px;
  width:auto;
}

JavaScript

jQuery(document).ready(function(){
	jQuery('#test').attr('src','https://www.gstatic.com/webp/gallery3/2.png');
  console.log(jQuery('#test').outerWidth());
  console.log(jQuery('#test').outerHeight());
});