Javascript examples for jQuery Method and Property:attr
Decrease image width by 50px
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("img").attr("width",function(n, v){ return v - 50;/*from ww w .j a v a2s . co m*/ }); }); }); </script> </head> <body> <img src="http://java2s.com/resources/a.png" alt="message" width="300" height="213"><br> <button>test</button> </body> </html>