jQuery attr()
with callback function
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"> </script>/*from www . ja va 2s . c o m*/ <script> $(document).ready(function(){ $("button").click(function(){ $("img").attr("width",function(n, v){ return v - 50; }); }); }); </script> </head> <body> <img src="image4.png" alt="image4.png" width="284" height="213"><br> <button>Decrease image width by 50px</button> </body> </html>